Thursday, June 1, 2006

VNC server howto


A brief VNC howto introduction:


What is VNC?

VNC stands for Virtual Network Computing. It is remote control software which allows you to view and interact with one computer (the "server") using a simple program (the "viewer") on another computer anywhere on the Internet. The two computers don't even have to be the same type, so for example you can use VNC to view an office Linux machine on your Windows PC at home. VNC is freely and publicly available and is in widespread active use by millions throughout industry, academia and privately.

VNC server Howtos in Fedora Core OS.

Do yout think I have it in installed from my system?

Type the following command to check if you have the client and server installed from your system.

As root
[root@deniro mail]# rpm -qa vnc vnc-server
vnc.i386.4.1.1-10.1
vnc-server.i386.4.1.1-10.1

Or as non-root user
[vertito@deniro ~]$
vnc.i386.4.1.1-10.1
vnc-server.i386.4.1.1-10.1

If it's not yet installed, you can install it using the easy to use yum command.

[root@deniro mail]# yum install vnc-server

Now, to configure vncserver as a service on your system, add yourself in following config file.

[vertito@deniro ~]$ sudo vi /etc/sysconfig/vncservers

# VNCSERVERS="1:myusername"
VNCSERVERS="1:vertito"

To add more users
VNCSERVERS="1:vertito 2:ver"

OPTIONAL:
VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
VNCSERVERARGS[2]="-geometry 800x600 -depth 8"

Before starting vncserver as a service, let's create a vnc password with vncpasswd command.
Notice it creates a hidden directory .vnc under your home account with file passwd which contains your vnc password.

[vertito@deniro ~]$ vncpasswd
Password:
Verify:
[vertito@deniro ~]$ ls -d .vnc
.vnc
[vertito@deniro ~]$ ls .vnc
passwd
[vertito@deniro ~]$

Now let's start vncserver as a service.

[vertito@deniro ~]$ sudo /sbin/service vncserver start
Starting VNC server: 1:vertito [ OK ]
[vertito@deniro ~]$

Take a look at the contents of .vnc directory now. You should have something similiar to following.

[vertito@deniro ~]$ cd .vnc
[vertito@deniro ~]$ ls
passwd vertito:1.log vertito:1.pid xstartup
[vertito@deniro ~]$

If you edit the script called xstartup, you will see UNSET SESSION_MANAGER 2 lines,
uncomment those two lines! Otherwise, you will get nothing but grey screen.
#!/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 &

After editing vnc startup script, we need to restart the vncserver service

[vertito@deniro ~]$ sudo /sbin/service vncserver restart
Shutting down VNC server: 1:vertito [ OK ]
Starting VNC server: 1:vertito [ OK ]
[vertito@deniro ~]$

So how do I connect to vncserver?
Use vncviewer command in vnc client as following.
[vertito@deniro ~]$ vncviewer localhost:1

Enter your password there.

General usage is:
vncviewer [Server's IP]:[Port]:[Display]

To connect to a remote system with iptables firewall, port 5901 needs to be open.
Add following line to open port 5901 and restart iptables service.

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

/sbin/service iptables restart

If you have 2 users, you may
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901:5902 -j ACCEPT

These would listen on ports 5901, 5902 respectively.

And restart again the following services,
/sbin/service iptables restart
/sbin/service vncserver restart

To load vncserver during reboot, add as startup service

#chkconfig vncserver on

To know vnc-server status

/sbin/service vncserver status

Basically, this is it. You are happy to go!

Further Reading
Read the man pages. Everything is in there:

man vncserver
man Xvnc
man vncconfig
man vncviewer
VNC with SSH. See http://www.ltsp.org/contrib/vnc.html

sources: Fedora, Fedora Forum, Fedora FAQ, Google

life:
teleportation is a must

Trademarks are their own copyrights.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy