我正在使用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代码做同样的事情?
答案 0 :(得分:0)
我找到的唯一解决方案是在$ HOME / .ssh / config`中配置library(data.table)
library(dplyr)
dat <- setDT(dt %>% group_by(id) %>%
unique() %>%
summarise(bldlog = mean(log),
art = gsub("X,|,X", "",paste(art, collapse = ","))))
dat
# id bldlog art
# 1: 1 11 Y
# 2: 2 11 X
# 3: 3 12 X
# 4: 4 12 Z,Y
# 5: 5 13 X
。
$ HOME / .ssh / config
的示例StrictHostKeyChecking
或
Host *
StrictHostKeyChecking no