sudo with -u via ssh -t in a crontab

Posted by DJK_devel on Server Fault See other posts from Server Fault or by DJK_devel
Published on 2011-02-17T18:16:50Z Indexed on 2011/02/17 23:27 UTC
Read the original article Hit count: 179

Filed under:
|
|

I'm trying to create a cron job that uses ssh to login to a remote server and run a script as a different user. I try:

* * * * * source $HOME/.keychain/$HOST-sh && sudo -u $USER $PATH/$SCRIPT

but this doesn't work because there is no -t option specified for ssh. The cron job needs to source the keychain file in order to work without a password, but I'm not sure where to include the -t option for ssh in this instance.

© Server Fault or respective owner

Related posts about ssh

Related posts about sudo