Sunday, May 22, 2011

vnc to current session on fedora

Been using fedora 14 and wanted to set up vnc to current session on the running gnome desktop

#install server
sudo yum install x11vnc-javaviewers x11vnc

#set x11vnc password, it is written to /home/yourusername/.vnc/passwd where yourusername is your usernmae
x11vnc -storepasswd

#run server
#-forever so that it does not disconnect when client disconnets
#-display :0 so that client shadows current logged in session
#-usepw so that client uses password from /home/yourusername/.vnc/passwd on server
#-bg can be used for the x11vnc to go into into the background after screen setup.Messages to
stderr are lost unless -o logfile is used
x11vnc -forever -usepw -display :0

#set up x11vnc startup in xinetd for autostart
sudo yum install xinetd
sudo vi /etc/xinetd.d/x11vnc
Enter following in the file
service x11vnc
port = 5900
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/x11vnc
server_args = -inetd -o /var/log/x11vnc.log -display :0 -rfbauth /home/yourusername/.vnc/passwd -many -bg
disable = no
Note here we are running the service as root so that it can access /var/log/x11vnc.log but use /home/yourusername/.vnc/passwd file created by yourusername

my x11vnc server was sometimes giving error, probably it may be starting before x windows. So I removed inetd and it's config and instead added following to /etc/gdm/PostLogin/Default

#Running x11vnc server
/usr/bin/x11vnc -o /var/log/x11vnc.log -display :0 -rfbauth /home/bhupendra/.vnc/passwd -many -bg

1 comment:

Anonymous said...

The "-many" and "-bg" options do not make sense in "-inetd" mode and are ignored. So you can remove them from your inetd command line and get the same result.