-
Notifications
You must be signed in to change notification settings - Fork 5
added env variables for ssh password and passphrase #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be not mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you can of course write it like that. How about you merge it and change this style detail then?
No description provided.