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
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.
-
Enable ssh-agent
ssh-add -L
ssh username@target_machine
ssh-add -D
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
user@gateway:~#
#Now you can ssh to your production server
user@gateway:~# ssh user@production_server
user@production_server:~#
You are successfully authenticated with the SSH key on your Desktop Machine.