Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python ssh without authenticity validation

Tags:

python

ssh

I am running a command remotely on an AWS machine like this:

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)

This works fine, but if it is the first login onto the machine I get the question:

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)

how do I "input" "yes" from python, or alternatively, use a flag to tell ssh not to ask the question?

like image 605
eran Avatar asked Jan 18 '26 05:01

eran


1 Answers

Try to pass -o StrictHostKeyChecking=no to the ssh command.

like image 105
vmalloc Avatar answered Jan 19 '26 20:01

vmalloc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!