I believe that you are using the wrong kind of quotes. A simple csh agent does nothing, you need to include the results of its launch using command substitution with:
eval `ssh-agent`
or
eval $(ssh-agent)
This causes the script to set the necessary environment variables. However, ssh-agent will still not have any keys unless you ssh-add them. If your keys do not have a passphrase, then ssh-add can simply be run from a script.
If your private key has a passphrase, you can run this script as a daemon, not a cron job. This will allow you to connect to the agent and add private keys.
The real reason the script runs from the command line is because your desktop environment is probably running ssh-agent , and it arranges the necessary environment variables for distribution in all of your terminal windows. (Either by making them children, and inheriting the variables, or having the shell source code the necessary commands.) I assume that you are running ssh-add at some point in your normal workflow?
Digitaloss
source share