Skip to content

Commit ed7a502

Browse files
author
Dan
committed
Check config exists
1 parent c1d5b51 commit ed7a502

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pssh/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ def read_openssh_config(_host, config_file=None):
7070
hostname, user, port and private key values
7171
7272
:param _host: Hostname to lookup in config"""
73-
ssh_config = SSHConfig()
7473
_ssh_config_file = config_file if config_file else \
7574
os.path.sep.join([os.path.expanduser('~'),
7675
'.ssh', 'config'])
7776
# Load ~/.ssh/config if it exists to pick up username
7877
# and host address if set
79-
if os.path.isfile(_ssh_config_file):
80-
ssh_config.parse(open(_ssh_config_file))
78+
if not os.path.isfile(_ssh_config_file):
79+
return
80+
ssh_config = SSHConfig()
81+
ssh_config.parse(open(_ssh_config_file))
8182
host_config = ssh_config.lookup(_host)
8283
host = (host_config['hostname'] if
8384
'hostname' in host_config

0 commit comments

Comments
 (0)