setting up x11vnc on Ubuntu 10


I have root access to a ubunut 10 VM which i normally connect to via putty. I am trying
I am a linux novice trying to connect to ubunutu 10 via x11vnc.

I have tried to install x11vnc on the machine as follows
sudo apt-get install x11vnc vnc-java
x11vnc -storepasswd

 iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5900 -j ACCEPT
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5800 -j ACCEPT

x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

 This seems to load ok but removes the shell prompt. I presume the server has started and is listening on the ports so i used another putty window to reconnect to my machine and ran sockstat -l and xllvnc is listening on the 2 ports.

 I then downloaded realvnc windows client and entered the hostname to connect
If i entered just the hostname or hostname:5900 i get a timeout error but if i enter hostname:5800 i get 'connection refused' error

I have been advised this is not the best way and i should start the server like so

x11vnc -auth -forever guess -display :0 -localhost -rfbport 20000 -xkb

 I tried starting the server like this but i got a warning saying i was running the server without a password.
There does appear to be an encrypted password in ~/.vnc/passwd though so i tried this instead

x11vnc -auth -forever guess -display :0 -localhost -rfbport 20000 -xkb -rfbauth ~/.vnc/passwd

There was some loading messages.
The root prompt returned so i assumed the server must be running in the background so i tried ps -ef | grep vnc to look for it but nothing was listed. How do i stop the vnc servers I have started???

I tried connecting via realvnc (with port 2000) but got connection refused. The linux machine uses a non-standard port for SSH so I don't know if realvnc is trying to connect via ssh over the standard port with forwarding to port 2000?

Note: please do not simply post a link to a website with instructions as your answer as I will not award the points. I have already looked at many websites and it seems I am unable to do this without some human guidance

thanks a lot
Who is Participating?
upanwarConnect With a Mentor Commented:
To set password for vnc, run the command
# vncpasswd

To check whether VNC is running or not execute the below given command.

# ps -ef | grep -i vnc

If it dont show anything it means that VNC is not running on your box.

To check on which post your VNC is listening just run the command.

netstat -natp | grep -i vnc

It will show you the port on which VNC is listening.

Check on which ports your box is listening.

netstat -an | grep "LISTEN"

Check the which ports are open with below given command.

iptables -L -v

To check from your windows box whether your Linux box is listening on particular box or not just run the below given steps.

Start ---> Run ----> cmd

on command prompt execute below given command

telnet <ip address of linux box> <port>

If you are getting ^ Escape character, it means port is open otherwise there is some problem like if you get error message 'connection refused' it means server is not running on that port.

Hope these steps will help you to troubleshoot your issue but still if you face any issue or have any query. Please feel free to ask us.
andiejeAuthor Commented:
it looks as though the vnc server is exiting as it loads.

It seems to start

06/03/2011 20:03:53 passing arg to libvncserver: guess
06/03/2011 20:03:53 passing arg to libvncserver: -rfbauth
06/03/2011 20:03:53 passing arg to libvncserver: /root/.vnc/passwd
06/03/2011 20:03:53 passing arg to libvncserver: -rfbport
06/03/2011 20:03:53 passing arg to libvncserver: 5900
06/03/2011 20:03:53 x11vnc version: 0.9.9 lastmod: 2009-12-21  pid: 27843
06/03/2011 20:03:53 Using X display :0
06/03/2011 20:03:53 rootwin: 0x101 reswin: 0x1600001 dpy: 0xbce480

then it ends like this and returns to the promopt

06/03/2011 20:03:53 Default visual ID: 0x21
06/03/2011 20:03:53 Read initial data from X display into framebuffer.
06/03/2011 20:03:53 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/3200
06/03/2011 20:03:53 *** unrecognized option(s) ***
06/03/2011 20:03:53     [1]  guess
06/03/2011 20:03:53 For a list of options run: x11vnc -opts
06/03/2011 20:03:53 or for the full help: x11vnc -help
06/03/2011 20:03:53
06/03/2011 20:03:53 Here is a list of removed or obsolete options:
06/03/2011 20:03:53
06/03/2011 20:03:53 removed: -hints, -nohints
06/03/2011 20:03:53 removed: -cursorposall
06/03/2011 20:03:53 removed: -nofilexfer, now the default.
06/03/2011 20:03:53
06/03/2011 20:03:53 renamed: -old_copytile, use -onetile
06/03/2011 20:03:53 renamed: -mouse,   use -cursor
06/03/2011 20:03:53 renamed: -mouseX,  use -cursor X
06/03/2011 20:03:53 renamed: -X,       use -cursor X
06/03/2011 20:03:53 renamed: -nomouse, use -nocursor
06/03/2011 20:03:53 renamed: -old_pointer, use -pointer_mode 1
andiejeAuthor Commented:
if i do the telnet command to the ssh port then it seems ok

if i used the vnc port i get the message 'connecting to server' and then the window closes automatically after about 30 secs
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

andiejeAuthor Commented:
the port 5900 appears to be open but i believe i don't need any other ports to be open to do ssh tunnelling

the first problem is that the vnc server is not starting
andiejeAuthor Commented:
i got the server to start and is listening on port 5900 - i checked all of the above.

x11vnc  -forever  -display :0 -localhost  -xkb -rfbauth ~/.vnc/passwd

 i then tried to set up the client like so:

Setup the Client PC:
Launch PuTTY.
Under session:
Host Name: your Unix box FQDN or IP
Click SSH
Give the session a name

Under: Connection / SSH / Tunnels
Enter a port forward for Local
Source Port: 5901
Destination: localhost:5900
Click Add

Click on session again and save it.

Now launch (Open) your PuTTY session and logon to your Linux box's SSH
 launch  VNC Viewer and enter localhost:1

with realVNC i got connection refused error 10061
Could you please run below given commands on your Linux box and provide the output.

netstat -an | grep "LISTEN"

ps -ef | grep -i vnc

iptables -L
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.