Tag Archives: ubuntu ssh-agent

Ubuntu ssh-agent autostart on login

ssh-agent provides a way of securely storing private keys for SSH applications. This means, all applications relying on SSH on the underneath like git or svn can be automatically the keys when you want to interact with a private remote code repository.

Many a time, I have been stumped by the ssh-agent not already running on my VPSes from Digital Ocean and Amazon when I’m logged in via SSH.

I would manually start the ssh-agent with the below command

And then manually add all the keys to the ssh-agent by running

We can verify whether the keys were added by typing

I had to do this every other day, and wanted to automate it. In the process, I landed upon this piece of shell code to automate this process.

Once this is added to your .bash_profile, every time you open a terminal, ssh-agent is started if it’s not running already and then all the key files are loaded into it.

For this to be applied to the currently running terminal, you need to run

Hope this helps!