Skip to content

Instantly share code, notes, and snippets.

@imShara
Last active September 12, 2019 08:38
Show Gist options
  • Save imShara/31e88d8a3a7a473b098233642ede21bc to your computer and use it in GitHub Desktop.
Save imShara/31e88d8a3a7a473b098233642ede21bc to your computer and use it in GitHub Desktop.
How to make SSH connection to device behind NAT

How to make SSH connection to device behind NAT

On natted device:

  1. Run sshd daemon
# systemctl start sshd
  1. Make reverse SSH connection
$ ssh -R 2222:localhost:22 user@host-with-white.ip

On host with white IP:

  1. Connect to natted device through tunnel
# ssh natted-device-user@localhost -p 2222
  1. Accept key and enjoy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment