Skip to content

Commit 89765d6

Browse files
author
Dan
committed
Fix regression when openssh config does not exist. Resolves #63
1 parent 39af4c3 commit 89765d6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pssh/ssh_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ def __init__(self, host,
9494
the SSH agent
9595
:type allow_agent: bool
9696
"""
97-
host, _user, _port, _pkey = read_openssh_config(
98-
host, config_file=_openssh_config_file)
97+
try:
98+
host, _user, _port, _pkey = read_openssh_config(
99+
host, config_file=_openssh_config_file)
100+
except TypeError:
101+
host, _user, _port, _pkey = host, None, 22, None
99102
user = user if user else _user
100103
client = paramiko.SSHClient()
101104
client.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())

tests/test_ssh_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,9 @@ def test_openssh_config(self):
327327
self.assertTrue(client.pkey)
328328
del _server, _listen_socket
329329

330+
def test_openssh_config_missing(self):
331+
client = SSHClient(self.host, _openssh_config_file='fake', num_retries=1)
332+
self.assertTrue(client)
333+
330334
if __name__ == '__main__':
331335
unittest.main()

0 commit comments

Comments
 (0)