Wednesday, July 11, 2012

To VNC through SSH

Assuming you have already set up openssh on the server (previous post) the instructions are as follows:

On the server:
install a VNC server such as x11vnc

sudo apt- get install x11vnc

your firewall settings should be as follows:

port 22 (ssh) should allow incoming connections from anywere

port 5900 (vnc) should be open to ip address 127.0.0.1 (local host)


On the Client:
install a VNC client such as gtkvncviewer

sudo apt-get install gtkvncviewer


Still on the client:
You can now  use local port-forwarding to connect port 5,900 on your server to port 5,900 your client.

ssh -L 5900:localhost:5900 <user>@<host>

note if using a port other than 22 for ssh add the -p XXXX option where XXXX is the port dedicated to ssh

Now that you are connected to the server issue the following cammand to enable the VNC session:

x11vnc -safer -localhost -nopw -once -display :0


Still on the client: 

You can now open gtkvncviewer from the menu or issue the command from a fresh terminal window (or new tab)

set the server to 127.0.0.1
enter your username  and password (for the server) to complete the connection

the server's desktop should appear after pressing "connect"

No comments:

Post a Comment