Python SSH using Popen
<p>How do I <code>ssh</code> using <code>Popen</code> by answering yes by default when faced with this?</p>

<pre><code>The authenticity of host '`XXXXX`' can't be established.
ECDSA key fingerprint is SHA256:LA2RqbdzD8Uxgi36KWOM12giS9T+ceOQYhYjVKReMks.
Are you sure you want to continue connecting (yes/no)?
</code></pre>

<p>this is what I'm trying</p>

<pre><code>for IP in ['10.32.253.250']:
    remoteCall = subprocess.Popen(["ssh", "co_user@"+IP, "sudo svstat /etc/sv/nagios_CheckDisk_Alertz_daemon",], stdout=subprocess.PIPE, stderr=subprocess.PIPE);
    Response, err = remoteCall.communicate()
    if(re.search("authenticity of host", Response)):
        stdin.write('yes')
    print IP + "  " +Response
</code></pre>

<p>Not sure how subprocess do it, next is another way, maybe helpful to you. FYI.</p>

<pre><code>import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.1.6", 22, "username", "password")
stdin, stdout, stderr = ssh.exec_command('ls') // your command here
content = stdout.readlines()
print content
ssh.close()
</code></pre>

python ssh subprocess popen