Ssh Agent Forwarding Inside Cron Jobs

ssh-agent and crontab -- is there a good way to get these to meet?

When you run ssh-agent -s, it launches a background process that you'll need to kill later. So, the minimum is to change your hack to something like:

eval `ssh-agent -s` 
svn stuff
kill $SSH_AGENT_PID

However, I don't understand how this hack is working. Simply running an agent without also running ssh-add will not load any keys. Perhaps MacOS' ssh-agent is behaving differently than its manual page says it does.

How to assign cronjobs from root to another user via SSH/PuTTY (Debian)?

If you want to list all available users in one server, you can run the following command

cut -d: -f1 /etc/passwd

You can then grep the output to check if the account exists

cut -d: -f1 /etc/passwd | grep my_user

If the user does not exist, you can create it using the following commands

useradd my_user
passwd my_user

Then, you can simply migrate the existing root crontab to the my_user crontab running the following commands as root:

mv /var/spool/cron/root /var/spool/cron/my_user
service crond restart

If that still does not work, you can try running these commands afterwards. These will add your user to the list of users who do have permission to run cronjobs:

echo "my_user" >> /etc/cron.allow
service crond restart

Hope it is useful!

capistrano ssh connection - doesn't work when ran from cron or teamcity

I fixed this by modifying the ssh connection in ssh/config, running ssh-agent with a specific pid, adding environment variables and adding a build step to add the key to the ssh agent in the running build.

http://petey5king.github.com/2011/12/09/deploying-with-capistrano-from-teamcity.html

git push via cron

As explained here, it can be due to the lack of knowledge from the cron session shell of the ssh agent.

If that is the case (ie if you are using private ssh keys with a passphrase), keychain is the usual solution (as mentioned here).

More details in this example: "Passwordless connections via OpenSSH using public key
authentication, keychain and AgentForward".



Related Topics



Leave a reply



Submit