@@ -46,15 +46,13 @@ def __init__(self, conn_params: ConnectionParams):
46
46
self .host = conn_params .host
47
47
self .ssh_key = conn_params .ssh_key
48
48
self .port = conn_params .port
49
+ self .ssh_cmd = ["-o StrictHostKeyChecking=no" ]
49
50
if self .ssh_key :
50
- self .ssh_cmd = ["-i" , self .ssh_key ]
51
- else :
52
- self .ssh_cmd = []
51
+ self .ssh_cmd += ["-i" , self .ssh_key ]
53
52
if self .port :
54
- self .ssh_cmd = ["-p" , self .port ]
53
+ self .ssh_cmd + = ["-p" , self .port ]
55
54
self .remote = True
56
55
self .username = conn_params .username or self .get_user ()
57
- self .add_known_host (self .host )
58
56
self .tunnel_process = None
59
57
60
58
def __enter__ (self ):
@@ -78,16 +76,6 @@ def close_ssh_tunnel(self):
78
76
else :
79
77
print ("No active tunnel to close." )
80
78
81
- def add_known_host (self , host ):
82
- known_hosts_path = os .path .expanduser ("~/.ssh/known_hosts" )
83
- cmd = 'ssh-keyscan -H %s >> %s' % (host , known_hosts_path )
84
-
85
- try :
86
- subprocess .check_call (cmd , shell = True )
87
- logging .info ("Successfully added %s to known_hosts." % host )
88
- except subprocess .CalledProcessError as e :
89
- raise Exception ("Failed to add %s to known_hosts. Error: %s" % (host , str (e )))
90
-
91
79
def exec_command (self , cmd , wait_exit = False , verbose = False , expect_error = False ,
92
80
encoding = None , shell = True , text = False , input = None , stdin = None , stdout = None ,
93
81
stderr = None , get_process = None , timeout = None ):
0 commit comments