Skip to content
Open
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
7 changes: 5 additions & 2 deletions sshtunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ def get_agent_keys(logger=None):
return list(agent_keys)

@staticmethod
def get_keys(logger=None, host_pkey_directories=None, allow_agent=False):
def get_keys(logger=None, host_pkey_directories=None, allow_agent=False, ssh_pkey_password=None):
"""
Load public keys from any available SSH agent or local
.ssh directory.
Expand Down Expand Up @@ -1106,6 +1106,7 @@ def get_keys(logger=None, host_pkey_directories=None, allow_agent=False):
if os.path.isfile(ssh_pkey_expanded):
ssh_pkey = SSHTunnelForwarder.read_private_key_file(
pkey_file=ssh_pkey_expanded,
pkey_password=ssh_pkey_password,
logger=logger,
key_type=paramiko_key_types[keytype]
)
Expand Down Expand Up @@ -1150,7 +1151,8 @@ def _consolidate_auth(ssh_password=None,
ssh_loaded_pkeys = SSHTunnelForwarder.get_keys(
logger=logger,
host_pkey_directories=host_pkey_directories,
allow_agent=allow_agent
allow_agent=allow_agent,
ssh_pkey_password=ssh_pkey_password or ssh_password,
)

if isinstance(ssh_pkey, string_types):
Expand Down Expand Up @@ -1315,6 +1317,7 @@ def read_private_key_file(pkey_file,
if logger:
logger.error('Password is required for key {0}'
.format(pkey_file))
raise
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this line necessary?

break
except paramiko.SSHException:
if logger:
Expand Down