Skip to content
Search

Ssh-agent

lastmod 2024-05-01created 2023-03-184 edits

Why use it?

So why use ssh-agent? Even without ssh-agent, you can connect to a remote server with an SSH key and no username or password. The reason has to do with the password you entered when generating the SSH key above. If you enter a password when generating an SSH key, you are asked for that password whenever you connect to a remote server with the key, and as you'll find after a few tries, this is quite a nuisance. You made an SSH key because you didn't want to enter a username and password, and then it asks you for a password again… This is when you use ssh-agent. Simply put, ssh-agent encrypts and remembers the private key's password, so you only enter the private key password once the first time, and after that the remembered password is used, so the user does not have to enter the password again. Since it communicates with the remote server by creating a Socket, there is no worry about the password being leaked either.

If you did not enter a password when generating the SSH key, you can consider ssh-agent to be of little real use.

Registering an SSH key with ssh-agent

Run the SSH agent in the background with the eval "$(ssh-agent -s)" command, then register the key with the SSH agent using the following command.

ssh-add ~/.ssh/id_rsa

Categories

Favorite site

author Zer0 sitemap