SSH Port Forwarding

SSH Port Forwarding
SSH Port Forwarding

It's possible to forward a port to another port with SSH port forwarding.

For example, configure the forwarding settings that the 8081 on the local is forwarded to the 5901(VNC) on the local. This example shows simply setting but it's possbile to forward most ports to most ports on the local or on other servers.

Start a VNC process on display #1 with a user, next, Configure like follows.
# forward the connection to 8081 to 5901 on local
jessie@dlp:~$ ssh -L 0.0.0.0:8081:localhost:5901 jessie@localhost
jessie@localhost's password:   # the password of the working user (it means the login to local to local)
Last login: Sat May 2 22:11:22 2015 from 10.0.0.5
# confirm
jessie@dlp:~$ netstat -lnp | grep 8081
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      1920/ssh

# keep this session and go next
# it's possbile to start the process on background as a daemon with "-f" option but then it needs to kill it by hand after working
Next, connect to the port configured above on the local.
Just connected like follows.
Port forwarding with Client Tools

It's possible to use the port forwarding function with tools which has it without configuring servers.
For example, connect to a server with VNC by using Putty's port forwarding.

Start a VNC process on a server with a user.
Start Putty on the ClientPC and specify the destination server.
Select "Connection" - "SSH" - "Tunnels" on the left menu and input any port which is free on the local PC on "Source port" field, and also input "[destination server]:[port]" on "Destination" field. Next, click "Add" button.
Make sure the setting is added and click "Open" button to connect.
Login to the server and keep the session, and go next step.
Start VNC client on the ClientPC and connect to [localhost]:[the port which you set as a source port].
Just connected.
DANS Media
Paham Ilmu, Kesehatan, dan Pengetahuan, tertarik dengan Financial Technology, mengajak banyak orang agar paham akan Ilmu dan Pengetahuan

Post a Comment

© DANS Media. All rights reserved. Distributed by DANS Media