From 2a909839ff2e84002307a3f4014442f6d03a12ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K?= Date: Wed, 19 Feb 2020 12:44:11 +0100 Subject: [PATCH] artiq_flash: added option of specifying another username when connecting through SSH. (#1429) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Kulik --- artiq/remoting.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/artiq/remoting.py b/artiq/remoting.py index 24e53b53a..41ca35928 100644 --- a/artiq/remoting.py +++ b/artiq/remoting.py @@ -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