ssh-agent - How to configure ssh-agent forwarding ?
Complete step by step tutorial on how to configure ssh-agent and ssh-agent forwarding
SSH agent allows you to store ssh keys, and certificates on memory in unencrypted format. ssh-agent acts as an ssh key manager which allows you to use ssh keys without entering a passphrase every time you log in.
root@server:~$ eval "$(ssh-agent -k)"
Agent pid 182 killed
SSH agent forwarding will allow you login to a distant remote machine by forwarding the SSH keys stored on your local SSH agent onto a host to which you are connecting. For example, you need to connect to your production servers via your gateway server. Then you can add your SSH key to your local desktop ssh-agent and it will forward to your production servers via your gateway server. So you need not add your SSH key to your gateway server.
1. Create or open up the file at ~/.ssh/config
ssh -A user@gateway
user@desktop:~# ssh -A user@gateway
#Now you can ssh to your production server
user@gateway:~# ssh user@production_server
You are successfully authenticated with the SSH key on your Desktop Machine.
FREQUENTLY ASKED QUESTIONS
1. What is SSH Agent?
An SSH agent, also known as an SSH authentication agent, acts as a secure key management tool for SSH keys. SSH agent securely stores SSH keys and certificates in memory in an unencrypted format. As a key manager, it eliminates the need to type the passphrase multiple times when logging in with an SSH key.
2. What is SSH agent forwarding?
SSH agent forwarding protocol allows secure access to remote servers through an intermediary server . This feature allows you to maintain the ability to authenticate using the SSH keys stored on your local SSH agent while navigating through the intermediate server.
3. Difference between SSH agent and SSH add?
ssh-add is a command line tool that helps to add private SSH keys to the SSH agent.When you run the ssh-add command, it will prompt you for a passphrase if you have set one which is needed to unlock your private key. Once you provide the passphrase, the command proceeds to integrate your private key into the ssh-agent.The passphrase acts as an additional layer of security and encryption for your private key.Adding your private key to the agent enables easy SSH authentication without repeatedly entering the passphrase.