Skip to content

Instantly share code, notes, and snippets.

@sergio-gimenez
Last active July 14, 2022 17:03
Show Gist options
  • Select an option

  • Save sergio-gimenez/c4fff0efed4c2250c25b25a0c27f0191 to your computer and use it in GitHub Desktop.

Select an option

Save sergio-gimenez/c4fff0efed4c2250c25b25a0c27f0191 to your computer and use it in GitHub Desktop.
Access any machine remotely using reverse SSH tunnel

How to access any machine through reverse SSH tunneling.

Things needed:

  • Restricted Machine: Machine unaccessible remotely that we want to have access.
  • Public Machine: A machine that can be accessed from anywhere. That might be because it uses a public IP or because it has a Dynamic DNS service such as DuckDNS or for other whatever reason.
  • Client to access the remote machine: Any machine that has internet access and SSH.

From restricted machine access public machine:

ssh username@publicIPaddress -R 5555:localhost:22

SSH to Public IP machine from the client:

ssh username@publicIPaddress -p 1598

Once inside the public machine, use reverse SSH to access the restricted machine:

ssh -p 5555 RestrictedMachineUsername@localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment