added env variables for ssh password and passphrase#6
added env variables for ssh password and passphrase#6DEvil0000 wants to merge 2 commits intoRedHatQE:masterfrom
Conversation
|
|
||
| `PASSWORD` - Password in case you do not use a private key (not recommended) | ||
|
|
||
| `PASSPHRASE` - Passphrase to your private key |
There was a problem hiding this comment.
Should be not mandatory.
There was a problem hiding this comment.
empty should work - I however did not explicitly test it without
| allow_agent=False, | ||
| timeout=20, | ||
| ) | ||
| if len(env.PASSWORD) > 1: |
There was a problem hiding this comment.
you should take into account the case when PRIVATE_KEY_PATH is not provided and PASSWORD is the only secret.
There was a problem hiding this comment.
I don't understand. PRIVATE_KEY_PATH is always provided by env.py even if PRIVATE_KEY was empty.
There was a problem hiding this comment.
PRIVATE_KEY_PATH is always provided by env.py even if PRIVATE_KEY was empty.
Sorry, I meant PRIVATE_KEY. It doesn't make sense to provide PRIVATE_KEY if you have PASSWORD and vice versa. They are mutually exclusive arguments.
def get_cred():
if env.PASSWORD:
return {"password": env.PASSWORD}
if env.PRIVATE_KEY:
pkey = paramiko.rsakey.RSASHA256Key.from_private_key_file(env.PRIVATE_KEY_PATH)
return {"passphrase": env.PASSPHRASE, "pkey": pkey}
raise ValueError("Either PASSWORD or PRIVATE_KEY must be defined")
...
ssh_client.connect(
hostname=ip,
username=env.USERNAME,
look_for_keys=False,
allow_agent=False,
timeout=60,
**get_cred()
)There was a problem hiding this comment.
yes, you can of course write it like that. How about you merge it and change this style detail then?
No description provided.