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

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

Popular posts from this blog

portage-2.2 preserve-libs FEATURES explained

Send $SGB (Songbird) to another wallet using a script

The diff between the original SEC complaint against Ripple and the amended one