artiq_flash: added option of specifying another username when connecting through SSH. (#1429)

Signed-off-by: Paweł Kulik <pawel.kulik@creotech.pl>
This commit is contained in:
Paweł K 2020-02-19 12:44:11 +01:00 committed by GitHub
parent 6d26def3ce
commit 2a909839ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -59,7 +59,11 @@ class LocalClient(Client):
class SSHClient(Client):
def __init__(self, host, jump_host=None):
self.host = host
if "@" in host:
self.username, self.host = host.split("@")
else:
self.host = host
self.username = None
self.jump_host = jump_host
self.ssh = None
self.sftp = None
@ -83,7 +87,7 @@ class SSHClient(Client):
self.ssh = paramiko.SSHClient()
self.ssh.load_system_host_keys()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(self.host, sock=proxy)
self.ssh.connect(self.host, username=self.username, sock=proxy)
logger.debug("Connecting to {}".format(self.host))
return self.ssh