Tuesday, 15 September 2015

linux - scp script runs perfectly under user but fails mysteriously under cron job -



linux - scp script runs perfectly under user but fails mysteriously under cron job -

i have python script performs scp operation transfer files 1 synology diskstation (running linux) several mac osx computers on local network. have setup rsa private/public key pairs on machines involved. if invoke python script nas drive admin user, works expected. nas drive crontab file specifies same admin user run script in exact same manner. however, scp fails exit status code of 1.

what cause behavior?

[update]

using scp -v (or scp -vv) reports more information. can see it's supplying right key , authentication working expected. notice has worked on few of osx machines, not of them.

i verified .ssh/known_hosts , .ssh/authorized_keys in place admin, not root. reason, when python script run under crontab, .ssh/known_hosts checked root known_hosts instead of admin user known_hosts. challenge brought during scp command , because wasn't tty, checked root known_hosts file, didn't find remote host , failed. after adding osx remote hosts known_hosts file, worked smoothly.

i think alternate (and more secure) solution have been install separate crontab under admin user, did faster.

linux security cron scp

No comments:

Post a Comment