Technology and troubleshooting.

Wednesday, December 30, 2015

Tunnelling VNC over SSH with PuTTY in linux

How to run VNC on a linux machine and connect to it securely over ssh tunneling.(Centos)

Setup VNC Server in Linux

Step 1:- Log into to your Linux machine

Step 2:- Make sure your Linux firewall is turned on and need to open port 22 to allow SSH connection

Apply the below comment to open iptables configuration using your favorite text editor 

[root@techreno.blogspot.com~]# vi /etc/sysconfig/iptables 

Add the below statement at the end of the line (to allow SSH Port 22)

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

Write the configuration

Restart the iptables to apply changes.

[root@techreno.blogspot.com~]#service iptables restart

telnet your-linuxmachine-IP 22 example : telnet 192.168.1.2 22

Telnet port 22

If you see above screen your configuration is correct because you have been open the port 22 to access SSH service

Step 2:- Configure linux server in Linux machine.

Set VNC password for linux machine

[root@techreno.blogspot.com~]#vncpasswd

Set VNC Password

Step 3:- Install Tight VNC software in windows machine

 telnet the vnc port 5900

Telnet the VNC Port 5900

It won't allow you to telnet the port 5900 because we are closed all the ports in linux firewall except port 22

Here is the Tricky part

Open the PUTTY

Enter your linux machine IP Address 

SSH Login
Then click on to the category select SSH-Tunnels

Tunnel Local to remote
Click Add button to add source port and destination port

Add the Configuration
 

 Now click on Open to login SSH session

Open the Putty session

It prompts for username and password for linux machine

Logon to your linux machine


Now open TightVNC viewer

             Enter   localhost:5900 

VNC localhost:5900


It will prompt for VNC Password Enter your VNC password




Finally your able to access your linux machine through VNC with out opening the vnc port 5900

Linux machine on VNC Viewer




NOTE: VNC connection is active until the PUTTY is open. If you close the PUTTY you will lose the VNC session



I hope this information is useful for you.



Share: