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