@@ -29,26 +29,33 @@ def __init__(self, host):
29
29
socket .AF_INET , socket .SOCK_STREAM )
30
30
self .host = host
31
31
self .port = None
32
+ self .user = None
32
33
if ':' in host :
33
34
self .host , self .port = host .split (':' )
35
+ if '@' in self .host :
36
+ self .user , self .host = host .split ('@' )
37
+
34
38
self .proc = None
35
39
36
40
def connect (self , ** kwargs ):
37
- port = '' if not self . port else '-p {}' . format ( self . port )
38
- args = [
39
- 'ssh' ,
40
- '-q' ,
41
- self .host ,
42
- port ,
43
- 'docker system dial-stdio'
44
- ]
41
+ args = [ 'ssh' ]
42
+ if self . user :
43
+ args = args + [ '-l' , self . user ]
44
+
45
+ if self .port :
46
+ args = args + [ '-p' , self . port ]
47
+
48
+ args = args + [ '--' , self . host , 'docker system dial-stdio' ]
45
49
46
50
preexec_func = None
47
51
if not constants .IS_WINDOWS_PLATFORM :
48
- preexec_func = lambda : signal .signal (signal .SIGINT , signal .SIG_IGN )
52
+ def f ():
53
+ signal .signal (signal .SIGINT , signal .SIG_IGN )
54
+ preexec_func = f
49
55
50
56
self .proc = subprocess .Popen (
51
57
' ' .join (args ),
58
+ env = os .environ ,
52
59
shell = True ,
53
60
stdout = subprocess .PIPE ,
54
61
stdin = subprocess .PIPE ,
@@ -124,9 +131,6 @@ def __init__(self, ssh_client=None, timeout=60, maxsize=10, host=None):
124
131
if ssh_client :
125
132
self .ssh_transport = ssh_client .get_transport ()
126
133
self .ssh_host = host
127
- self .ssh_port = None
128
- if ':' in host :
129
- self .ssh_host , self .ssh_port = host .split (':' )
130
134
131
135
def _new_conn (self ):
132
136
return SSHConnection (self .ssh_transport , self .timeout , self .ssh_host )
@@ -169,7 +173,10 @@ def __init__(self, base_url, timeout=60,
169
173
self ._create_paramiko_client (base_url )
170
174
self ._connect ()
171
175
172
- self .ssh_host = base_url .lstrip ('ssh://' )
176
+ self .ssh_host = base_url
177
+ if base_url .startswith ('ssh://' ):
178
+ self .ssh_host = base_url [len ('ssh://' ):]
179
+
173
180
self .timeout = timeout
174
181
self .max_pool_size = max_pool_size
175
182
self .pools = RecentlyUsedContainer (
0 commit comments