Wednesday, March 11, 2015

Connecting to your machine using vnc

To setup and use vncserver in redhat flavored distro, please follow below steps:

  1. Install the package:
    $ sudo yum install tigervnc-server tigervnc
  2. Set a password for a user that you want to use to login to the vnc server:
    $ vncpasswd
  3. Start the vncserver:
    $ vncserver
  4. Check the display number of your newly created vnc session:
    $ vncserver -list
    TigerVNC server sessions:
    :1              9168
  5. Check the port that your vnc session is using:
    $ sudo netstat -tulpn | grep 9168
    tcp        0      0      *                   LISTEN      9168/Xvnc
    tcp        0      0      *                   LISTEN      9168/Xvnc
    tcp        0      0 :::6001                     :::*                        LISTEN      9168/Xvnc
  6. Test your vncserver locally (only if you are using GUI, else test it from the other machine with vncviewer installed), using vncviewer (belongs to tigervnc package):
    $ vncviewer :1

To connect from a redhat flavored linux distro client:
  1. Install the tigervnc package:
    $ sudo yum install tigervnc
  2. Run the vncviewer: vncviewer :
    $ vncviewer
  3. If you are behind firewall, you need to open port 5901 for the client to get through.
  4. If firewall is not in your control, you can always use ssh to port forward port 5901 to 5901 in your localhost, by: 
  5. $ ssh -L 5901:localhost:5901 vncserver.ip.address
    and in other terminal, run
    $ vncviewer localhost:1

Once you are done, you can kill the server by running:

$ vncserver -kill :1