SSH Port Forwarding2014/08/02
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
ssh -L 0.0.0.0:8081:localhost:5901 cent@localhost
# the password of the working user (it means the login to local to local)
Last login: Thu Jul 10 01:35:15 2014
# make sure
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 3238/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 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 with VNC.|