Skip to content
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

Do not provide the key if it comes from the SSH configuration #648

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/jnpr/junos/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def _sshconf_lkup(self):
self._hostname = found.get('hostname', self._hostname)
self._port = found.get('port', self._port)
self._conf_auth_user = found.get('user')
self._conf_ssh_private_key_file = found.get('identityfile')
return sshconf_path
Copy link
Contributor

@vnitinv vnitinv Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why is this lined removed.
So if I have entered my private ssh file as identityfile in my ssh cofig. witout this line those private key file will be ignored and its like everytime user need to pass with ssh_private_key_file parameter.

In case of multiple device usage with different private file for different device. identityfile is of much use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The information is still present in the SSH configuration that is provided to ncclient. So, your use case still work.

The line is removed because when _conf_ssh_private_key_file is defined, it disables the SSH agent (which is quite surprising as no other SSH client does that). So, if the key is stored in the agent, that doesn't work.


def display_xml_rpc(self, command, format='xml'):
Expand Down Expand Up @@ -830,15 +829,13 @@ def __init__(self, *vargs, **kvargs):
# user will default to $USER
self._auth_user = os.getenv('USER')
self._conf_auth_user = None
self._conf_ssh_private_key_file = None
# user can get updated by ssh_config
self._ssh_config = kvargs.get('ssh_config')
self._sshconf_lkup()
# 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')
self._auth_password = kvargs.get(
'password') or kvargs.get('passwd')

Expand Down