# VNCServer (Linux) Setup and Client Configuration (Win)

## MatzeOne

This is my first tutorial and english is not my first language, so please don't hack me  :Wink: 

This tutorial should guide you trough the installation of a VNC Server on (Gentoo) Linux and the configuration for Windows Boxes.  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 client on another computer. If you want to surf webpages at your work and your boss shouldn't know that, i'm your man  :Wink: 

Before we start make sure you can answer at least the first four questions with yes:

- Do you have a Linux installed on your computer which you want to use as your server?

- Do you have a Windows installed on the computer which you want to use as your client?

- Do you have root access to your Server?

- Do you have a Secure Shell Daemon installed, configured and is it started?

- Do you know why you want to follow the following instructions?

---

So we can start now with the Linux Server.

I'm using the Gentoo distribution so i can't guarantee that this works on your box. I recommend Gentoo as the best distribution around, but that's not the topic  :Wink: 

Log in as root.

Gentoo-users:

Update the portage tree with 

```
emerge sync
```

 You make sure that you've the latest versions by updating the portage tree. Next get the vnc-package and compile it: 

```
emerge vnc
```

Now the server is ready  :Smile: 

Non-Gentoo-Users:

You should get the package from http://www.realvnc.com manually. Follow the installation instructions.

Now start the server by typing this into the terminal, shell or whatever  :Wink:  

```
vncserver
```

When vncserver is started for the first time you have to enter a password. For security reasons don't use your root password or another password you are using  :Wink:  Re-enter the password. The server should have been started and is listening to port 5901 per default.

You can check with 

```
nmap localhost
```

These ports should show up:

```
PORT      STATE SERVICE

5801/tcp  open  vnc-http-1

5901/tcp  open  vnc-1

```

If you are behind a firewall, make sure port 5901 open. On port 5801 there is a webserver with a java-applet installed. You can access your machine by simply typing http://your-linux-server:5801 but then the data is not encrypted and the local system administrator may have some questions  :Wink:  So just don't use this ^^

---

Client setup (Windows)

We need some programs to be installed  :Smile: 

Download and install Putty - It's the SSH client. We use this because of security reasons  :Smile: 

Download VNC for Windows. You don't need to fill our the fields on the download side. Just click on the checkbox left of Windows 9x/2000/NT/XP (x86) and proceed. You only need the viewer.

After Installing these programs we will configure Putty.

Start Putty

Session:

___Hostname: ip of server

___Port: port on which sshd listens (default: 22)

NOTE: by accessing your computer over a hostname instead of an ip, get you an account at http://www.dyndns.org per example.

Connection:

###Proxy: if you connect through a proxy to the internet, enter the information

Connection:

###SSH

________Tunnels:

________________Disable X11 Forwarding

________________(add new lokal port): Source port: 5901

----------

## Malakin

If you want a more responsive connection this is what I use to connect from a windows box:

tightvncviewer.exe /encodings tight /compresslevel 9 /quality 5 /nocursorshape -normalcursor -noremotecursor whatever.dyndns.org:1

I use tightvnc instead of the standard vnc, it has quite a few additional features and it's rock solid. jpeg support is one of the tightvnc features and it's much faster using it.

This enables jpeg compression and cranks up the cpu usage for compression although it's still very low on my systems. nocursorshape stops the cursor shape updates, normalcursor gives you a normal arrow cursor to work with and noremotecursor prevents the real cursor from being drawn.

----------

## MatzeOne

thx 4 the tip, Malakin  :Very Happy: 

i'll try this tool l8er  :Smile: 

----------

## ferris5

When i start vncserver i get the following : couldn't find "xauth" on your PATH.

what am i doing wrong?

----------

## MatzeOne

 *ferris5 wrote:*   

> When i start vncserver i get the following : couldn't find "xauth" on your PATH.
> 
> what am i doing wrong?

 

did you start the server as root?

so did i (yes... i know... i shouldn't do this...) and it worked for me

----------

## ferris5

Yes, that was the answer, thanks

----------

## MatzeOne

 *ferris5 wrote:*   

> Yes, that was the answer, thanks

 

you're welcome  :Smile: 

----------

## Hoshimaru

Very interesting ^^

However I only see a X shell window on a gray background.

I logged in using SSH.

# vncserver

# startx

Wether I run startx or not, I get the same gray bg with a shell window. Any idea ?

Edit: Screenshot

----------

## Malakin

 *Quote:*   

> Wether I run startx or not, I get the same gray bg with a shell window. Any idea ?

 I think you need to edit your ~/.xinitrc file and add a line for a desktop.

Mine looks like this:

```
/usr/kde/3.1/bin/startkde
```

----------

## Hoshimaru

Ok ^^

I'm going to find out what command is needed for Gnome  :Smile: 

Edit: Screenshot - Direct access on the Gentoo box, without VNC and SSH

----------

## Hoshimaru

I managed to get it working.

I commented everything in ~/.vnc/xstartup and wrote:

```

#!/bin/sh

xset fp+ unix/:-1

/etc/X11/Sessions/Gnome

```

I found this on the gentoo forums during my coffee break at work, but I can't remember which thread it was.

Maybe this can help someone else too ?

Screenshot

----------

## HomerSimpson

MatzeOne, if we are tunneling through ssh then why do we have to open 5901 in the firewall?

I ask this because I can't get this to work outside my lan. I am assuming that port 5901 needs to be open but I don't understand why and I don't want to open it if I don't have to.

Thx for the tutorial.  :Smile: 

----------

## marcowave

 *MatzeOne wrote:*   

>  *ferris5 wrote:*   When i start vncserver i get the following : couldn't find "xauth" on your PATH.
> 
> what am i doing wrong? 
> 
> did you start the server as root?
> ...

 

it doesn't work for me...

I am root but I when I type vncserver I get this error:

couldn't find "xauth" on your PATH

 :Sad: 

----------

## meulie

 *marcowave wrote:*   

>  *MatzeOne wrote:*    *ferris5 wrote:*   When i start vncserver i get the following : couldn't find "xauth" on your PATH.
> 
> what am i doing wrong? 
> 
> did you start the server as root?
> ...

 

I had that as well. The following command solved it for me:

```

source /etc/profile

```

----------

## marcowave

ok, now I have VNC working..

but it's too slow... I can't control my remote PC server with a Linux VNC server.. so I reinstalled win2000..

is there some other programs faster than VNC or is there a way to make VNC for linux faster?

----------

## meulie

have you tried tightvnc?  works pretty good on my systems here...    :Cool: 

----------

## marcowave

yep I try it...

it works well with a normal X session...

but if I use KDE it's very slow....

Are u using KDE?

----------

## meulie

Yup.  I use both Gnome & KDE.

My linux box is a 2.4G Celeron & my winXP is a Athlon XP 2000+. I've set tightvnc to max compression.

----------

## marcowave

how have I to modify the file 

#/home/johnny/.vnc/xstartup

```

#!/bin/sh

xrdb $HOME/.Xresources

xsetroot -solid grey

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

twm &

```

to make KDE starts up in a VNC session?

----------

## Malakin

KDE has support for vnc. Control Center -> Internet & Network -> Desktop Sharing. From here you can tick "allow uninvited connections" and give it a password.

Not sure how fast KDE's built-in vnc support is, it may be a lot slower then tightvnc but I don't know since I haven't used it recently.

----------

## marcowave

 *Malakin wrote:*   

> KDE has support for vnc. Control Center -> Internet & Network -> Desktop Sharing. From here you can tick "allow uninvited connections" and give it a password.
> 
> Not sure how fast KDE's built-in vnc support is, it may be a lot slower then tightvnc but I don't know since I haven't used it recently.

 

yes I know.. but it is too slow..

and for fluxbox? what I have to change?

----------

## x20vmk4x

 *marcowave wrote:*   

>  *Malakin wrote:*   KDE has support for vnc. Control Center -> Internet & Network -> Desktop Sharing. From here you can tick "allow uninvited connections" and give it a password.
> 
> Not sure how fast KDE's built-in vnc support is, it may be a lot slower then tightvnc but I don't know since I haven't used it recently. 
> 
> yes I know.. but it is too slow..
> ...

 

just change the 

```
twm&
```

 to 

```
fluxbox&
```

----------

## pele_smk

ok I'm getting the error: 

vncserver: Could not create /home/pelesmk/.vnc.

Any suggestions?

*FIXED* Wow an intersting one. Simple yet weird, It ended up being an ownership problem. As basic as not being allowed to write to /home/pelesmk/. Must have been a late night and I messed something up. All is well now.

----------

## wesblake

Ok guys, this is the first time I've set up vncserver. I followed this guide, and my comp is at home behind a Wireless router. I set up the router to forward port requests for 5801 and 5901 to my box under "virtual server" tab.

I then started server (as normal user, not root) and got this:

bash-2.05b$ vncserver

You will require a password to access your desktops.

Password:

Verify:

xauth: (argv):1:  bad display name "tux:1" in "add" command

New 'X' desktop is tux:1

Creating default startup script /home/daho/.vnc/xstartup

Starting applications specified in /home/daho/.vnc/xstartup

Log file is /home/daho/.vnc/tux:1.log

bash-2.05b$ nmap localhost

bash: nmap: command not found

bash-2.05b$ /sbin/nmap localhost

bash: /sbin/nmap: No such file or directory

bash-2.05b$ su

Password:

bash-2.05b# nmap localhost

bash: nmap: command not found

bash-2.05b# exit

exit

Well, I got on my Windows (laptop) and grabbed TightVNC, started it up, and entered my.ip.here:5901 and clicked ok, it says "Failed to connect to server"

So...I went to IE and put in http://my.ip.here:5801

The Java application comes up, I type in my password and click ok, it gives me a shell. I type startx, and it says "Server is already active for display 0", I'm assuming because I'm on it right now. But in the above output it said:

New 'X' desktop is tux:1

Doesn't this mean the VNC will use display 1?

Thanks for any help, I don't really want to use the web one, I'd like to use TightVNC. Also, what's the best way to connect from another linux box?

Thanks peeps.

----------

## wesblake

Oh, and I'm assuming since I started the server under my login, and it asked me for a password then, it's only running the server for me to connect to? Basically, I want to get this thing set up so that I and one other user on my computer can both connect to it. Thanks again.

***edit***

Ok, so I got it to connect, I had to do my.ip.here:1

So it comes up on my TightVNC (Windows) but it's just a grey background with the X mouse icon I can move around, and a console. When I VNC into school, I get the login prompt and can login to an X-session. I'd like to use KDE as it's what I have installed on my linux box, how can I do that? Thanks.

***edit***

Sorry peeps, guess I asked the questions before looking for the answers, go figure. I think this is what I was looking for:

https://forums.gentoo.org/viewtopic.php?t=72893&highlight=vnc

----------

## bannedillo

I am using SSH, and after put "emerge vnc" and all process is ok then i put "vncserver" and i get this "-bash: vncserver: command not found".     I cant understand whats going on.

Thanks guys

----------

