When using SSH with public-key authentication, ‘ssh-agent
‘ is a useful compromise between storing the SSH private key un-encrypted to disk and having to type the key`s passphrase every time you need to make an SSH connection.
When using SSH from scripts, things are further complicated, because no one is around to type in the passphrase. From this reason, SSH keys that are used by servers are, more often then not, stored with no encryption, thereby becoming a lucrative target for hackers.
With some clever manipulation, a script can be written in such a way where it can make use of the ‘ssh-agent
‘ to load and use an encrypted private key.