SSH - using keys works, but not in a script

Posted by Garfonzo on Server Fault See other posts from Server Fault or by Garfonzo
Published on 2011-11-29T00:04:59Z Indexed on 2011/11/29 1:52 UTC
Read the original article Hit count: 577

Filed under:
|
|

I'm kind of confused, I have set up public keys between two servers and it works great, sort of. It only works if I ssh manually from a terminal. When I put the ssh command into a python script, it asks me for a password to login. The script is using rsync to sync up a directory from one server to the other.

manual ssh command that works, no password prompt, automatic login:

 ssh -p 1234 [email protected]

In the Python script:

rsync --ignore-existing --delete --stats --progress -rp -e "ssh -p 1234" [email protected]:/directory/ /other/directory/

What gives?

(obviously, ssh details are fake)

© Server Fault or respective owner

Related posts about linux

Related posts about ssh