Skip to content

Commit

Permalink
Merge pull request #2000 from ceph/user
Browse files Browse the repository at this point in the history
orchestra: Respect username if set in ssh config
  • Loading branch information
dmick authored Aug 20, 2024
2 parents 67db276 + ce2f484 commit 4d4c5e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion teuthology/orchestra/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ def connect(user_at_host, host_key=None, keep_alive=False, timeout=60,
key_filename = key_filename or config.ssh_key
ssh_config_path = config.ssh_config_path or "~/.ssh/config"
ssh_config_path = os.path.expanduser(ssh_config_path)
if not key_filename and os.path.exists(ssh_config_path):
if os.path.exists(ssh_config_path):
ssh_config = paramiko.SSHConfig()
ssh_config.parse(open(ssh_config_path))
opts = ssh_config.lookup(host)
if not key_filename and 'identityfile' in opts:
key_filename = opts['identityfile']
if 'hostname' in opts:
connect_args['hostname'] = opts['hostname']
if 'user' in opts:
connect_args['username'] = opts['user']

if key_filename:
if not isinstance(key_filename, list):
Expand Down

0 comments on commit 4d4c5e3

Please sign in to comment.