【发布时间】:2017-08-14 22:02:08
【问题描述】:
我正在使用 salt-ssh 和命令行,我可以使用选项 -i 来使用“StrictHostKeyChecking”
(agent) [root@NODE ~]# salt-ssh 'af0abc4b-6980d-4fdd-ba63-192cb3d116be' test.ping
af0abc4b-6980d-4fdd-ba63-192cb3d116be:
----------
retcode:
254
stderr:
stdout:
The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:
The authenticity of host '10.10.10.10 (10.10.10.10)' can't be established.
ECDSA key fingerprint is af:00:b8:ab:7a:3e:cd:06:9a:6c:36:e9:32:f0:a3:a4.
Are you sure you want to continue connecting (yes/no)?
(agent) [root@NODE ~]# salt-ssh -i --no-host-keys 'af0abc4b-6980d-4fdd-ba63-192cb3d116be' test.ping
af0abc4b-6980d-4fdd-ba63-192cb3d116be:
True
但是当我想用 python api 做同样的事情时,我没有找到指定 -i 选项的方法,所以可以这样做。
这是我正在使用的python代码
from salt.client.ssh.client import SSHClient
salt = SSHClient()
salt.cmd('af0abc4b-6980d-4fdd-ba63-192cb3d116be', 'test.ping')
Out:
{'af0abc4b-6980d-4fdd-ba63-192cb3d116be': {'retcode': 254,
'stderr': '',
'stdout': "The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:\nThe authenticity of host '10.10.10.10 (10.10.10.10)' can't be established.\nECDSA key fingerprint is af:00:b8:ab:7a:3e:cd:06:9a:6c:36:e9:32:f0:a3:a4.\nAre you sure you want to continue connecting (yes/no)? "}}
我怎样才能对 python 代码做同样的事情??
【问题讨论】: