SSH to intranet hosts from outside – SSH gateway

For some of the latest projects I’m working on, it is required that I quite frequently access various machines that are located behing a corporate firewall, on a privately adressed subnet inside a company.

One option I had but got fed up with quite fast was :

 outside$ ssh nicolas@gateway 
 gateway$ ssh root@box1 
 ssh -t nicolas@gateway ssh root@box1

Once again, SSH came in handy and I found that everything was there for me to have that first hop and re-ssh done automatically. Just added the following to my ~/.ssh/config

 Host gateway       
 User nicolas 

 Host box1       
 User root       
 ProxyCommand ssh gateway nc -w 1 %h 22

This, coupled to ssh’s passwordless authentication made my day a lot easier ;)

Tags: ,

Leave a Reply