How to ssh-add in cron job

EDIT: updated link in this article.

ssh-add can let your ssh-agent remember the passphrase of your ssh
secret key, so that you don't need to type any password when loging
into a remote machine.
However, it is an interactive program, you can't call it in a cron
job. Even if you can, you will expose your passphrase in a file, which
is not safe.

The solution is actually very easy. You don't really need to ssh-add.
All you need to do is letting ssh know some environment variable.

First of all, I recommend you set up ssh-agent forwarding with GNU
screen following instruction here:
http://www.deadman.org/sshscreen.php
Then in your cron job script, source ${HOME}/bin/fixssh first.
Done!

Enjoy ;)

Comments

geekounet said…
Keychain was designed for this job too ;)
Anonymous said…
The URLin the article is stale.

Popular posts from this blog

Ripple's XRP: Giving the Third-Largest Cryptocurrency a Second Look

Illinois Is Venezuela and the Solution Is Cryptocurrency