0
我與鹽SSH和使用命令行,我可以使用-i選項使用「StrictHostKeyChecking」鹽SSH:禁用SSH主機與Python API密鑰檢查
(agent) [[email protected] ~]# 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) [[email protected] ~]# 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代碼相同?