2

I want to use VNC for remote access to a local Centos 6.4 desktop. I've installed tigervnc server, set a password for the user, opened port 5901 in the firewall, and started the vnc server. I tried to connect from another desktop, but get the message:

connection to host 192.168.1.23 was closed

When I try from the commandline, I get this:

vncviewer: ConnectToTcpAddr: connect: No route to host

Searching for an answer, I found that I should change the server settings to allow users to view desktop. I can't find a GUI tool to change this, and am not sure if this is the problem.

How can I get this working?


Update:

Below the code from ~/.vnc/xstartup (from the user)

#!/bin/sh

[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
#unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
  exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
3
  • 1
    You should check whether this is a problem on the network layer or on the application layer. If the latter is the case then you should adapt the title of your question as it would be misleading then. You can check with telnet 192.168.1.23 5901. Do you get a connection (which gets closed by the other side) or not even that? Commented Apr 3, 2014 at 16:28
  • I get this: Connected to 192.168.1.213., Escape character is '^]'. and RFB 003.008
    – SPRBRN
    Commented Apr 4, 2014 at 7:55
  • That means it's not a networking problem but a VNC configuration problem. Commented Apr 4, 2014 at 8:00

1 Answer 1

3

As a root user, perform the below steps.

vim /etc/sysconfig/vncservers

Add the below 2 lines (where vncuser will be your username).

VNCSERVERS="1:vncuser"
VNCSERVERARGS[1]="-geometry 1600x1200"

Then type the below commands.

service vncserver start
service vncserver stop
chkconfig vncserver on

If the above commands are successful, we need to edit the xstartup file for whom we have configured the vncserver. So, in our case, we have configured it for the user vncuser.

su vncuser
vi ~/.vnc/xstartup

Uncomment the below 2 lines.

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

If the above step is also successful, we are finished with the configuration of the VNC server. If you need more information, I had written a documentation on setting up the VNC server here.

2
  • I added the contents of .vnc/xstartup to my question. I uncommented both lines, although there are two with xinitrc in it. It didn't help - still no connection.
    – SPRBRN
    Commented Apr 4, 2014 at 8:08
  • Using another VNC viewer, it suddenly worked. The default Ubuntu viewer doesn't work. SSL/SSH VNC Viewer and GTK VNC Viewer both work.
    – SPRBRN
    Commented May 5, 2014 at 15:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .