Saturday, May 24, 2014

SSH Agent Forwarding


Scenario

  • - Password login is disabled on both the servers Node1 and Node2
  • - Your public key is added to both the servers Node1 and Node2 when they were created. (for example using OpenStack)
  • - Firewall rules only allow access to Node1


Question
- How to login to Node2

Solution: Enable agent forwarding


  •  Add your ssh private key to ssh forwarding agent

 ssh-add -c  ~/.ssh/your_private_key

  •  ssh to Node1 by enabling agent forwarding, like so:

 ssh user@Node1 -A

  •  Once you login to Node1, you can login again to Node2

 ssh user@Node2

  •  You can combine both steps into 1 command like so

 ssh user@Node1 -A -t ssh user@Node2