没有真实性验证的python ssh

时间:2013-04-30 12:19:14

标签: python ssh

我在AWS计算机上远程运行命令,如下所示:

key = 'myPemFile.pem'
target = <machine_ip>
cmd = 'ssh -i ' + key + ' ubuntu@'+target+' "nohup myprog + ' >& /dev/null < /dev/null &" &'
proc = subprocess.Popen(cmd, shell=True,  stdout=subprocess.PIPE)

这很好用,但如果它是第一次登录到机器上,我会得到一个问题:

The authenticity of host '144.224.18.97 (144.224.18.97)' can't be established.
ECDSA key fingerprint is e2:4e:...:e3:73:07.
Are you sure you want to continue connecting (yes/no)

如何从python“输入”“是”,或者使用标志告诉ssh不要问这个问题?

1 个答案:

答案 0 :(得分:4)

尝试将-o StrictHostKeyChecking = no传递给ssh命令。

相关问题