Friday, April 24, 2020

Reverse tunnel for jump servers(Great for working with NATed machines with no known IP)




This post is designed to help you set up a jump server for a VM/machine inside a NAT with no port FW option or if you are not the NAT/router admin so you cant FW any ports. this is done via a free tier AWS Ubuntu VM but can be done on any Linux box with internet access.



  1. Open SSH tunnel from the VM behind the NAT:(you can choose whatever port you like, in this case I used 9090)
  2. From the NATed VM run:  ssh  -L 9090:localhost:9090 ubuntu@ec2-13-59-192-175.us-east-2.compute.amazonaws.com -i "my-key-pair.pem”   
  3. Open a new command line on the NATed VM and create the reverse tunnel. run: ssh -R 22222:localhost:22 -i "my-key-pair.pem" ubuntu@ec2-13-59-192-175.us-east-2.compute.amazonaws.com
  4. Now anyone who connects to the AWS VM from anywhere can run the following command and get access to all ports on the NATed VM, run(core=user on the NATed VM): sudo ssh -D 9090 core@localhost -p 22222
  5.  Enjoy


No comments:

Post a Comment