cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
263
Views
0
Helpful
3
Replies

Python script - unable to set encrypted preshared key

MrNox
Level 1
Level 1

Hi there,

I'm trying to set an encrypted preshared key on a C9200 (ver 17.06.05) with a python script. 

When executing the following script

 

 

import cli
cli.configurep([
	"password encryption aes",
	"key config-key password-encrypt MYKEY"
])

 

 

I get the following output :

Line 1 SUCCESS: password encryption aes
Line 2 SUCCESS: key config-key password-encrypt MYKEY

However the second line is not configured.

Did I miss something ?

Regards

3 Replies 3

Try

 

import cli

cli.enable()
cli.configure(["crypto key generate rsa general-keys modulus 1024"])

config = [
    "password encryption aes",
    "key config-key password-encrypt MYKEY"
]

cli.configure(config)

 

 The cli.configure() method takes a list of configuration commands and executes them in config mode. 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

First try, I had to remove ,cli.enable() because of this : "AttributeError: module 'cli' has no attribute 'enable''"

After a second try, the rsa key pairs were generated successfully. The "password encryption aes" command was executed successfully but the "key config-key password-encrypt MYKEY" command still fails to work. When trying to set an encrypted key for radius or tacacs+ servers, I receive invalid key error messages. This suggests that encrypted preshared key is not set properly.

Ruben Cocheno
Spotlight
Spotlight

@MrNox 

Has this been resolved?

Tag me to follow up.
Please mark it as Helpful and/or Solution Accepted if that is the case. Thanks for making Engineering easy again.
Connect with me for more on Linkedin https://www.linkedin.com/in/rubencocheno/