Setup reverse ssh on Ubuntu
This guide will walk you through the process of setting up a reverse proxy using ngrok. This enables you to access your machine remotely over SSH, even if it's behind a NAT or a firewall.
Installation and Setup
Follow these steps to install ngrok, configure your firewall, and set up the SSH server:
snap install ngrok # install ngrok
# login to https://ngrok.com/ and follow ubuntu instructions
ngrok tcp 22 # open reverse ssh on port 22
# above command will print things, and a line will be like this:
# Forwarding tcp://0.tcp.ngrok.io:12345 -> localhost:22
# now you can ssh into your machine from anywhere in the world using:
ssh -o ServerAliveInterval=60 username@0.tcp.ngrok.io -p 12345
# but wait, there are probably couple of other things to do with your firewall
sudo ufw allow 22 # allow port 22 on your firewall, the port you are using for ssh (ufw : uncomplicated firewall)
sudo ufw allow tcp # allow tcp
# if necessary, disable firewall
sudo ufw disable
# install openssh-server if not installed
sudo apt get install openssh-server # install ssh server
sudo systemctl start ssh # start ssh server
sudo ufw allow ssh # allow ssh on firewall
Additional Notes
Once you have set up ngrok, you can use the forwarding address provided by ngrok to access your SSH server. Remember to replace "username" with your actual username and "12345" with the port number shown in the ngrok output.
Adjust your firewall settings carefully. Disabling the firewall completely can expose your system to vulnerabilities. It's recommended to only open the necessary ports.
For more detailed information, visit the official ngrok documentation.
Incoming Internal References (0)
Outgoing Internal References (0)
Outgoing Web References (1)
-
ngrok.com/docs
- ngrok documentation