eXTReMe Tracker
May 112011
 

For the first time I was able to get VNC to work with Ubuntu with Gnome session instead of a xterm on gray background. The steps involved were exactly the same as I was following earlier, with one exception: the setup of xstartup in the ~/.vnc folder.

For your xstartup file in ~/.vnc (the “.vnc” folder in

your home directory), you need the following:

#—————————–

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session &

# twm &

#————————

instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

make sure restart vnc4server

The line which got Gnome working was “gnome-session &”

========================================

Now for all the steps involved (works in Karmic Koala Alpha 2, Ubuntu 9.10, kernel 2.6.30-10)

1. Install ssh server, ssh client, VNC viewer, VNC server, and xinetd

sudo apt-get install openssh-server openssh-client vnc4server xinetd vncviewer

2. Setup the ssh password for your login

ssh-keygen

3. Test out the ssh server by typing in

ssh localhost or ssh your_login@your_ip_address

4. Then create a vnc password

sudo vncpasswd ~/.vncpasswd

5. Edit the xstartup file in ~/.vnc directory

For your xstartup file in ~/.vnc (the “.vnc” folder in

your home directory), you need the following:

—————————–

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session &

# twm &

————————

instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

6. Create a VNC desktop

vnc4server :1 -geometry 1024×768

7. Then to tunnel into your VNC desktop, first create a SSH tunnel by logging into SSH with the comand:

ssh -L 5901:your_ip_address:5901 your_username@your_ipaddress

8. Finally, load up your VNC desktop

vncviewer localhost:1

And now you are ready to use connect to your machine remotely and use administer the computer remotely.

P.S: If you are using a firewall (hardware or software, you need to get enable port forwarding and unblock ports 22 and 5900-5999 on the Ubuntu machine to allow SSH and VNC to be accessed.

  11 Responses to “VNC server setup for Ubuntu 11.04 (Natty Narwhal)”

  1. Thank you for this guide, But how I can run this commands ? :S

  2. Adjust your firewall:

    sudo ufw allow proto tcp from any to any port 5900:5999

    Sheers

  3. Thank you. but please post with screen shots, it would helpfull.

    Thanks,

    TechHowKnow

  4. why is it so hard? On windows you download tightvnc .. install.. boom it works.

    I don’t understand all this

  5. @הורדות
    Start Applications/Accessories/Terminal from the “start menu”.

  6. if I change “gnome-session &” to “xfce-session &” it’ll still work, right? The computer I’m running as a server is a salvaged Pentium 3 with only 384MB of RAM running Xubuntu with XFCE sessions to save RAM, so it’s important that I at least try to use XFCE instead of the heavier Gnome, so I don’t unnecessarily bog down my machine

  7. Hi,
    My goal is to allow some authorized people to connect to home PC for training purposes. I need a VNC environment so that they can use when required X-windows for practice lessons.

    As for my testing: Via my own local network I am able to do desktop sharing and controlling from my macbook. Here again, it requires the user already connected to remote desktop. But I need the person to connect afresh. I have already setup secure shell and I can do ssh via port 22.

    I want to follow your approach, that I should initiate a ssh and then start vncviewer on the remote machine to get the desktop. This way the user is in control to start X display only when required and it iss secure as well. But I am not able to achieve this. Please see my attempts from my macbook pro.

    Any help is highly appreciated.

    OS-X-Leopard:~ admin$ ssh -L 5903:192.168.2.6:5903 bab4l8m@192.168.2.6
    bab4l8m@192.168.2.6′s password:
    Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-13-generic x86_64)

    * Documentation: https://help.ubuntu.com/

    19 packages can be updated.
    14 updates are security updates.

    New release ‘oneiric’ available.
    Run ‘do-release-upgrade’ to upgrade to it.

    Last login: Thu Jan 5 07:09:34 2012 from os-x-leopard.local
    bab4l8m@ubuntu:~$ export DISPLAY=os-x-leopard.local
    bab4l8m@ubuntu:~$ vncviewer localhost:3
    Error: Can’t open display: os-x-leopard.local
    bab4l8m@ubuntu:~$ export DISPLAY=localhost:3
    bab4l8m@ubuntu:~$ vncviewer localhost:3
    No protocol specified
    No protocol specified
    No protocol specified
    No protocol specified
    Error: Can’t open display: localhost:3
    bab4l8m@ubuntu:~$ export DISPLAY=0:3
    bab4l8m@ubuntu:~$ vncviewer localhost:3
    No protocol specified
    No protocol specified
    No protocol specified
    No protocol specified
    Error: Can’t open display: 0:3
    bab4l8m@ubuntu:~$

  8. Jagan: If you want to connect to the Ubuntu machine using a macbook, you need to launch the vnc session on your macbook. The VNC client for OSX is Chicken of the VNC.

    Fire up the terminal and connect to your Ubuntu machine using ssh like you did.
    You then need to start a vnc session. You’ll do that by typing:

    vncserver :3 -geometry 1200×800

    I am assuming that you have already made changes to the xstartup file in .vnc folder.

    Once vncserver session has been started on Ubuntu side, you need to launch Chicken of the VNC on your mac.

    In there, you connect to localhost :3, give your password, and you should be in.

    Hope this helps.

  9. Will this allow me to run a headless server?

  10. Yes. One important step would be to make sure you always shutdown with a restart option if you want to have the servers running again. Always use:

    shutdown -r 0

  11. After many days of looking for a “RDP” like solution for the 11.X builds of ubuntu I finally found a very elegant solution on another site. I wanted to share it in hopes of saving others like myself a little time.

    Source
    http://mlepicki.com/2011/10/remote-vnc-login-to-ubuntu-11-10/

    “Today I’ve installed Ubuntu 11.10 Oneiric Ocelot on my ASrock 100HT nettop. I’ve wanted to remotely control this box via VNC protocol.
    My solution was x11vnc server, so I could share one one session between remote and physical access. I’ve found useful thread about x11vnc on Ubuntu 11.10 – I’ve just added some upstart magic to start x11vnc after lightdm.
    First of all, I’ve installed x11vnc:
    apt-get install x11vnc
    Then, I’ve created /etc/init/x11vnc.conf file:
    start on login-session-start
    script
    x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -o /var/log/x11vnc.log
    end script
    After restart, x11vnc shoud listen on vnc startard port – 5900.
    This script is of course based on upstart event mechanism. Lightdm emits login-session-start event (you can find it in lightdm.conf), and we start x11vnc when this event is emited – that’s first line of x11vnc.conf file.”

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>