Reverse SSH Tunneling
-
Working Mechanism of Reverse
SSH
Tunneling -
Reverse Tunneling With
SSH
-
Construct an
SSH
Tunnel in the Reverse
You can utilize that established connection to create a new connection via reverse SSH
tunneling from your local computer to the remote computer.
Because the connection was established from the distant computer to you, using it in the other manner is referred to as “in reverse”.
You’re also establishing a secure connection inside an existing secure connection because SSH
is secure. It means that your remote computer connection functions as a private tunnel within the original connection.
Working Mechanism of Reverse SSH
Tunneling
The remote computer uses the established connection to listen for additional connection requests from the local machine in reverse SSH
tunneling.
On the local computer, the remote machine listens on a network port. It sends the connection request down the http
connection back to itself if it detects an SSH
request for that port.
It establishes a new connection between the local and remote computers.
Reverse Tunneling With SSH
You need to install the OpenSSH
server before using it, but you haven’t done so yet. Install the OpenSSH
server to resolve the issue.
$ sudo apt install openssh-server
If the local machine has never previously accepted SSH
connections, you may need to activate the SSH
daemon sshd
.
$ sudo systemctl start sshd
Construct an SSH
Tunnel in the Reverse
We can use the ssh
command to connect to a remote server.
$ ssh [your-account-login]@[server-ip]
Once you’ve formed the connection, a person on the remote server-side, such as a system administrator, should run the following command.
$ ssh -fN -R 8080:localhost:92 username@yourMachine-ipaddress.
SSH
connection requests for port 8080
on your system will be sent to port 92
on the remote server with this connection request. Request for an SSH
connection from your machine to your machine.
You’ll establish a connection to port 8000
in this phase.
$ ssh username@localhost -p 8000
Your request will then be forwarded to the remote server. As a result, when requested for these details, use your remote server account login
and password
.
You can also use SSH
keys to make connecting from a remote computer to a local computer more secure. Type the following command on the remote computer.
$ ssh-keygen
To construct a secure password
, use four words separated by symbols and ensure that only those who know the phrase can access your computer over SSH
without asking for a password
.
You must also use the ssh-copy-id username@localhost
command to copy the created key
to your local computer.