HOWTO: Perfect Headless Server Setup with Secure VNC and RDP.
For this guide, we'll assume you are already comfortable with the text editor
of your choice and can edit and save system wide config files that require
root privilege without further instruction.
Also, We'll assume you are running the Desktop Edition of Ubuntu 9.10 Karmic Koala.
It should be easily adaptable to the Server Edition but I think it really needs to be Karmic or later.
Using the Desktop Edition makes it a little more difficult so we should cover all of the "Gotchas."
First of all, any server worth its salt has a static I.P. address and always brings up networking on boot.
In other words, we are about to go beyond the use case of NetworkManager,
so let's just turn it off! Edit "/etc/network/interfaces" to make it look like this:
^replacing all of the 192.168.*.* with suitable values for you network, of course.Code:# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.100.10 netmask 255.255.255.0 network 192.168.100.0 broadcast 192.168.100.255 gateway 192.168.100.1
Next edit "/etc/resolv.conf"
^replacing with your network info as necessaryCode:# /etc/resolv.conf nameserver 192.168.100.1 nameserver 192.168.100.2 search example.com
Starting with Karmic, certain lucky init scripts now live in "/etc/init/"
and are fully Upstart-able.
NetworkManager is one of these, so disabled it like so:
Now, Restart the machine and make sure networking is OKCode:sudo mv /etc/init/network-manager.conf{,.disabled}
Like the static IP, any good server also has SSH, this is important to us
because our VNC server will only accept local or SSH-tunnel connections, so
We need to turn off and disable gdm, so our VNC can be running on Display :0Code:sudo apt-get install openssh-server
Log in to the real console(Ctrl+Alt+F1) and do it Upstart style!
We need to install a standalone VNC server, tightvnc gave me troubleCode:sudo stop gdm sudo mv /etc/init/gdm.conf{,.disabled}
by mangling remote keyboard input, so I'm using vnc4server:
We need to pick a user for autologin in VNC, for this, we'll assume it's the user "mark"Code:sudo apt-get install vnc4server
We need to set mark's VNC password, run `vnc4passwd` as mark
Now we will see the beauty in Upstart, we are going to write a 100% valid
initscript in less than 15 lines.
Create "/etc/init/vnc-mark.conf" like this:
^remember to replace "mark" with your usernameCode:# vnc-mark.conf start on runlevel [2345] stop on runlevel [016] pre-start script su mark -c 'vnc4server :0 -geometry 1024x768 -localhost' end script post-stop script su mark -c 'vnc4server -kill :0' end script #End of File
Now we are ready to start the VNC service, Upstart style!
That's it for the VNC portion, you can't stop here if you don't want RDP support.Code:sudo start vnc-mark
RDP is "Remote Desktop Protocol" for [Gasp] Windows machines. Sometimes it's
convenient to be able to control your headless Linux box from a Windows PC without
having to install additional software in Windows, some people are touchy about that!
Life without Walls sure can make you paranoid! Cold and damp too I guess.
We're going to use a very narrow bit of the xrdp software's powers,
all we want it to do for us is be a translator for VNC and RDP.
So, install it and immediately stop it(not Upstart style :'[)
Edit/Demolish "/etc/xrdp/xrdp.ini" to this:Code:sudo apt-get install xrdp sudo service xrdp stop
^again change "mark" to suit your needs, I was nice and used comments for Demolition.Code:[globals] bitmap_cache=yes bitmap_compression=yes port=3389 crypt_level=low channel_code=1 [xrdp1] name=mark@VNC lib=libvnc.so username=na password=ask ip=127.0.0.1 port=5900 [xrdp2] name=disabled #lib=libvnc.so #ip=127.0.0.1 #port=5900 #username=na #password=ask # [xrdp3] name=disabled #lib=libvnc.so #ip=ask #port=ask5900 #username=na #password=ask # [xrdp4] name=disabled #lib=libvnc.so #ip=ask #port=-1 #username=ask #password=ask # [xrdp5] name=disabled #lib=librdp.so #ip=ask #port=ask3389 # [xrdp6] name=disabled #lib=libxup.so #username=ask #password=ask #ip=127.0.0.1 #port=-1
Fire up xrdp again:That's all Folks!Code:sudo service xrdp start
Control your headless box from other Linux boxes with this:
^replace username@IP as neededCode:vncviewer -via mark@192.168.100.10 localhost
the `-via` option tells `vncviewer` to use the SSH tunnel
the "localhost" bit is tricky because you have to specify the
hostname from the point of view of the SSH tunnel
If you did the last bit you can also control from "Remote Desktop Viewer" on a PC.



Adv Reply





Bookmarks