Home > Linux, Red Hat / CentOS, Ubuntu > Fjärrstyra en Ubuntu server via VNC

Fjärrstyra en Ubuntu server via VNC

September 8th, 2010 Leave a comment Go to comments

To remote control a Linux server, you really only need SSH access.

But if you need GUI access, for security, I would either use X11 forwarding through a SSH session or set up VNC tunneled through SSH.

For X11-forwarding, you need to edit the /etc/ssh/sshd_config file to allow it and just SSH in with:

 ssh -X user@host

For tunneling VNC through SSH, the best tutorial/how-to is probably using x11vnc and ssvnc:

With this setup, you don’t have a VNC server running all the time so not just anyone can connect.  When you run ssvnc (or sshvnc), it connects to the server through SSH and then starts the VNC server listening only on localhost and connects to that server.  When you log out of your SSH session, it kills the running VNC server.  All in all much more secure this way if the X11 forwarding won’t work for you.

If you’d like to run VNC all the time

Read how to use x11vnc here: http://www.karlrunge.com/x11vnc/x11vnc_opts.html

“Typical usage is:

Run this command in a shell on the remote machine “far-host”
with X session you wish to view:

 x11vnc -display :0

Then run this in another window on the machine you are sitting at:

 vncviewer far-host:0

Once x11vnc establishes connections with the X11 server and starts listening
as a VNC server it will print out a string: PORT=XXXX where XXXX is typically
5900 (the default VNC server port).  One would next run something like
this on the local machine: “vncviewer hostname:N” where “hostname” is
the name of the machine running x11vnc and N is XXXX – 5900, i.e. usually
“vncviewer hostname:0”.

By default x11vnc will not allow the screen to be shared and it will exit
as soon as the client disconnects.  See -shared and -forever to override
these protections.  See the FAQ for details how to tunnel the VNC connection
through an encrypted channel such as ssh(1).  In brief:

 ssh -t -L 5900:localhost:5900 far-host 'x11vnc -localhost -display :0'
 vncviewer -encodings 'copyrect tight zrle hextile' localhost:0

Also, use of a VNC password (-rfbauth or -passwdfile) is strongly recommended.

For additional info see: http://www.karlrunge.com/x11vnc/
and  http://www.karlrunge.com/x11vnc/faq.html

Regards, Tobias

Remote CentOS X from Windows via SSH

Run yum install vnc.

Another option is to use an X-windows with PuTTY/SSH client and configure the  X11 display to redirect for the SSH connection.

cygwin might be an option to explore ( www.cygwin.com )
What it will do is that once you establish an SSH connection from the windows 7 to the linux system with the X11 tunnel, you can then run the graphic commands on the linux and it will be redirected back through the SSH connection.
When in the SSH session on the linux, echo $DISPLAY to make sure it is set.

Categories: Linux, Red Hat / CentOS, Ubuntu Tags:
  1. No comments yet.
  1. No trackbacks yet.