How to forward local keypair in a SSH session?
This turned out to be very simple, complete guide is here Using SSH Forwarding
In essence, you need to create a ~/.ssh/config
file, if it doesn't exist.
Then, add the hosts (either domain name or IP address in the file and set ForwardAgent yes
)
Sample Code:
Host example.com
ForwardAgent yes
Makes SSH life a lot easier.
- Create ~/.ssh/config
Fill it with (host address is the address of the host you want to allow creds to be forwarded to):
Host [host address] ForwardAgent yes
If you haven't already run ssh-agent, run it:
ssh-agent
Take the output from that command and paste it into the terminal. This will set the environment variables that need to be set for agent forwarding to work. Optionally, you can replace this and step 3 with:
eval "$(ssh-agent)"
Add the key you want forwarded to the ssh agent:
ssh-add [path to key if there is one]/[key_name].pem
Log into the remote host:
ssh -A [user]@[hostname]
From here, if you log into another host that accepts that key, it will just work:
ssh [user]@[hostname]