How to use ssh-agent for authentication on Linux / Unix
ssh-agent is a program that allows you to store your private SSH keys in memory, so that you don't have to enter the passphrase every time you use them.
To use ssh-agent for authentication on Linux or Unix, you can follow these steps:
- Start by starting the ssh-agent program by running the following command:
eval "$(ssh-agent -s)"- Next, add your private key to the ssh-agent by running the following command:
ssh-add ~/.ssh/id_rsa- You will be prompted for your passphrase, enter it and your private key will be added to the ssh-agent.
- You can now use the ssh-agent to authenticate with a remote server using your private key without having to enter the passphrase again.
- To check which keys are currently managed by ssh-agent you can run the command
ssh-add -l, it will show the fingerprints of the keys. - To remove a key from the ssh-agent you can run the command
ssh-add -d /path/to/key. - To make the ssh-agent start automatically when you log in, you can add the
eval "$(ssh-agent -s)"command to your shell profile file (e.g .bash_profile or .bashrc). - To make it even more convenient, you can use a ssh-agent manager like keychain, ssh-agent forwarding, ssh-ident or ssh-agent-filter.
