Posted by Helder Guerreiro
This post show how you can access a remote network with a ssh tunnel assuring a secure connection.
You just type in on a terminal:
$ ssh -l USER -L LOCAL_PORT:REMOTE_IP_ADDRESS:REMOTE_PORT REMOTE_SERVER "perl -e 'while(1) {sleep 30}'"
Explaining the command:
- USER will be the user of the remote ssh server
- LOCAL_PORT is the local port that we will use to connect to the remote host
- REMOTE_IP_ADDRESS is the remote host IP adress
- REMOTE_PORT is the remote host connection port
- REMOTE_SERVER is the URL of the remote server
as example, if we have a remote network with a server called ssh.example.com that supplies an external SSH service and if we want to access a HTTP server on a host 192.168.212.1 inside that remote network, we do:
$ ssh -l sysadm -L 1234:192.168.212.1:80 ssh.example.com "perl -e 'while(1) {sleep 30}'"
Locally we do on a browser http://localhost:1234 to access the remote host.
The peral part that you see on the command will keep the connection on.