Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 &
share|improve this question
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? –  Hauke Laging Apr 3 at 16:28
    
I get this: Connected to 192.168.1.213., Escape character is '^]'. and RFB 003.008 –  SPRBRN Apr 4 at 7:55
    
That means it's not a networking problem but a VNC configuration problem. –  Hauke Laging Apr 4 at 8:00
add comment

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Apr 4 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 May 5 at 15:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.