-
Notifications
You must be signed in to change notification settings - Fork 344
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
Lookup user from ~/.ssh/config #628
Lookup user from ~/.ssh/config #628
Conversation
@stacywsmith and @vnitinv to review |
@@ -833,11 +833,11 @@ def __init__(self, *vargs, **kvargs): | |||
self._conf_ssh_private_key_file = None | |||
# user can get updated by ssh_config | |||
self._ssh_config = kvargs.get('ssh_config') | |||
self._sshconf_lkup() |
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 agree adding this line which will override self._conf_ssh_private_key_file None value set in line 833 if that is configured in ssh config file.
# but if user or private key is explicit from call, then use it. | ||
self._auth_user = kvargs.get('user') or self._conf_auth_user or \ | ||
self._auth_user | ||
self._ssh_private_key_file = kvargs.get('ssh_private_key_file') \ | ||
or self._conf_ssh_private_key_file | ||
self._ssh_private_key_file = kvargs.get('ssh_private_key_file') |
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.
why "or self._conf_ssh_private_key_file" was removed. If user has configured private key file in ssh config file, by removing the code the value will be set to None only.
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 are right. I don't know why I removed it. I have amended the commit.
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.
find my comments inline to code changes.
Due to a change in commit b03e611, the user wasn't extracted from user (or specified) SSH configuration. Add back the call to parse SSH configuration. Also, don't use the parsed private keyfile as it will be done automatically by the underlying Paramiko. Using the parsed key doesn't work, either because this is a list and not a string or because it is encrypted and I am using an agent.
e1187aa
to
9d91b76
Compare
This is a followup of Juniper#628 where this change was initially pushed but reverted because I didn't remember why I did it. Before Juniper#628, when an identity is provided in the SSH configuration, it was not copied in `_conf_ssh_private_key_file` due to a bug. After fixing the bug in Juniper#628, the key is now copied. However, the SSH configuration is provided to the `connect()` method which will use it if needed. Therefore, this is not needed. Moreover, if the key is provided by an agent and/or encrypted, this won't work as, later in the code, `allow_agent` will be set to `False` due to the presence of a private key.
Due to a change in commit b03e611, the user wasn't extracted from
user (or specified) SSH configuration. Add back the call to parse SSH
configuration.
Also, don't use the parsed private keyfile as it will be done
automatically by the underlying Paramiko. Using the parsed key doesn't
work, either because this is a list and not a string or because it is
encrypted and I am using an agent.