forked from M-Labs/artiq
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:
parent
6d26def3ce
commit
2a909839ff
|
@ -59,7 +59,11 @@ class LocalClient(Client):
|
||||||
|
|
||||||
class SSHClient(Client):
|
class SSHClient(Client):
|
||||||
def __init__(self, host, jump_host=None):
|
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.jump_host = jump_host
|
||||||
self.ssh = None
|
self.ssh = None
|
||||||
self.sftp = None
|
self.sftp = None
|
||||||
|
@ -83,7 +87,7 @@ class SSHClient(Client):
|
||||||
self.ssh = paramiko.SSHClient()
|
self.ssh = paramiko.SSHClient()
|
||||||
self.ssh.load_system_host_keys()
|
self.ssh.load_system_host_keys()
|
||||||
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
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))
|
logger.debug("Connecting to {}".format(self.host))
|
||||||
return self.ssh
|
return self.ssh
|
||||||
|
|
Loading…
Reference in New Issue