Permanently add a private key to SSH-agent

I think, we all had to face situation, when we need use ssh-key instead usual bundle of login and password. As for me, I remember that I was surprised when after system reboot, I must import SSH key again, that to eventually connect to remote server. So, today, we’ll be resolve this problem. Let’s start! 😉

How to permanently add a private key to SSH-agent?

Problem: How to permanently add a private key to SSH-agent?

Solution:

0. Firstly, we should know where is location folder for ssh keys. Generally it's: /home/username/.ssh/id_rsa For get this info will require input next command:

ssh-add

1. Next step, we move our key to .ssh folder that is here /home/username/.ssh/

2. Further open the file .config here /home/username/.ssh/.config and add next strings:

Host 8.8.8.8
IdentityFile ~/.ssh/our-key.pem

, where
8.8.8.8 — address of the host, also we can use domain name
~/.ssh/our-key.pem — relative path to our key

Thats all!

Sources:

  1. https://stackoverflow.com/questions/3466626/how-to-permanently-add-a-private-key-with-ssh-add-on-ubuntu

Leave Comment

Your email address will not be published. Required fields are marked *