20

Starting VNC server using vncserver :1, client can connect to the server but it shows only a black screen with a X curser.

Contents of .vnc/xstartup is:

#!/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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

Is it a problem with this?

user2656114
  • 949
  • 4
  • 18
  • 35

6 Answers6

17

That has happened to me 2x, and I have been able to repair it 2x. It's very likely only step 2. then 3. are required, but once I've found a way that works I'm loath to change...

  1. The .vnc/xstartup file was owned by root, so I changed ownership to user:
    chown user /home/user/.vnc/xstartup
  2. The .vnc/xstartup file was 664 (-rw-rw-r--.) - I assume vnc uses the 'other' permissions to connect and allow interactions, so I changed the permissions to 755:
    chmod 755 /home/user/.vnc/xstartup
  3. Restart the vncserver daemon:
    service vncserver stop; service vncserver start
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
Christian
  • 171
  • 1
  • 3
4

I was facing the same issue and it got resolved by commenting the last line and adding the gnome line in /home//.vnc/xstartup file as shown below:

#!/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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session&

Note: my GUI session handler was gnome so it worked.

Rajen
  • 931
  • 6
  • 8
4

I had same issue with new redhat linux 6.4. Got it working by installing basic desktop by the command yum groupinstall basic-desktop

Viswanath
  • 101
  • 2
  • 8
  • 1
    This worked for me on RHEL 6.7 but it installs a LOT of stuff so it shouldn't be the first solution for high performance servers. – emery Jan 26 '16 at 00:05
2

In addition to the other answers here, I also had to modify my xstartup script using the following script:

#!/bin/sh

# Change "GNOME" to "KDE" for a KDE desktop, or "" for a generic desktop
MODE=""

#Uncommment this line if using Gnome and your keyboard mappings are incorrect.
#export XKL_XMODMAP_DISABLE=1

# Load X resources (if any)
if [ -e "$HOME/.Xresources" ]
then
xrdb "$HOME/.Xresources"
fi

# Try a GNOME session, or fall back to KDE
if [ "GNOME" = "$MODE" ]
then
if which gnome-session >/dev/null
then
gnome-session --session=ubuntu-2d &
else
MODE="KDE"
fi
fi

# Try a KDE session, or fall back to generic
if [ "KDE" = "$MODE" ]
then
if which startkde >/dev/null
then
startkde &
else
MODE=""
fi
fi

# Run a generic session
if [ -z "$MODE" ]
then
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startx &
fi

I used this site to help me on that: http://ubuntuforums.org/archive/index.php/t-2131958.html. But I had to adapt it to my case, since I'm using Rocks Cluster distro, which is based on CentOS.

Erick Sperandio
  • 198
  • 2
  • 14
0

Try deleting the xstarup file (/home/.vnc/xstartup) and retype in the vnc password to create a new xstartup file and the restart vnc server service: sudo rm xstartup vndpasswd Verify passwd sudo service vncserver restart

-2

You might want to check that your server, you are trying to use vnc on, has some memory etc. available. I had memory leaking firefox open on my server and that was the reason for the vnc not working properly.