Quantcast
Channel: Linux – Computing
Viewing all articles
Browse latest Browse all 10

VNC over SSH

$
0
0

VNC over SSH

Setting up VNC server

General

  • Never use root user to start your VNC server
  • Always login as SysAdmin or a power user account to start your VNC server
  • You may want to tweak xstartup script under .vnc of your home directory for VNC server start up
  • For example:

ls -al /home/myusername/.vnc
(OR)
cd
cat .vnc/xstartup

TightVNC server on Ubuntu

  • Checking whether your TightVNC server Xtightvnc is up

ps aux|grep Xtightvnc

  • If VNC server is already running, the terminal message will return something like the following.

Xtightvnc :1 -desktop hostname -auth /home/username/.Xauthority -geometry 1024x768 -depth 16 -rfbwait ...
username  ......... grep Xtightvnc

  • If VNC server is not running yet, the terminal message will just return grep command message.

username  ......... grep Xtightvnc

For CentOS

Starting VNC server

  • To start tightvncserver or vncserver, execute the following command as SysAdmin (NOT as root)

vncserver :1 -geometry 1024x768 -depth 16 -name hostname

  • If it is the first time using vncserver command, you will be prompted to enter VNC display password and viewer only password. Do set the display password now but you can alter later with vncpasswd.
  • You may want to write a short shell script for shortening above command. This is optional.

cd
touch startvncserver.sh
echo "#!/bin/sh \n vncserver :1 -geometry 1024x768 -depth 16 -name hostname" > startvncserver.sh
chmod 755 startvncserver.sh
./startvncserver.sh

  • Stop/Kill tightvncserver

vncserver -kill :1

  • Note that where :1 is screen display number. You may change this display to some other number of your choice.
  • To set/reset VNC display password

vncpasswd

Connecting VNC client through SSH Tunneling/Port Forwarding

On Mac/Linux

  • This section is to be done at client computer, laptop or workstation that connect to VNC server.
  • You will at least require VNC viewer application in your client machine.

Method 1

  • On Mac, GNU/Linux and BSD, use the following SSH command to connect your VNC server

user@localhost$ssh -L 5901:localhost:5901 username@hostname.com

  • Now the ssh connection shall be forwarded to your localhost machine’s port 5901
Mac User
  • Mac user can download and use Chicken of the VNC
  • At host field, enter localhost
  • At display field, enter 1. Take note display number should tally with your vncserver setup.


Method 2

  • If you can have vncviewer command, you can use -via to connect your VNC server.
  • This is normally on GNU/Linux

user@localhost$vncviewer -via username@hostname.com localhost:1

  • Note that where :1 is display number which should tally with your VNC server start up.
  • After executed above command, the vncviewer GUI client will be launched automatically and you will be asked for VNC display password.

On Windows

  • Start PuTTY new session with your IP

  • At PuTTY navigation nodes, goto Connection > Tunnels. At source port field, fill 5901 (or port number which your VNC server listener on). At destination field, fill localhost:5901. You may play around with port number, this is your current local machine port. Make sure which ever port you’ve chosen should be free/available.

  • If satisfy with above setting, press add button.

  • Now go back to Session node, give session name to save the session setting.

  • Pressing save button will save these setting.

  • Finally, you may press open button to start your normal PuTTY SSH connection to your server. Supply your login name and password to login as per normal.
  • Next, start your favorite VNC viewer.

RealVNC Viewer

  • At server field, enter localhost:1.

  • Your VNC display password.

TightVNC Viewer

  • At server field, enter localhost:1.

  • Your VNC display password.

Take note, :1 denote 5901 of your localhost port. So, 5092 for :2 and so ford.


Viewing all articles
Browse latest Browse all 10

Trending Articles