How to Setup a VPS using Debian 6 Linux (32 Bit)

Why do I choose Debian? Well, beside it’s “pretty easy” to setup, I think Debian is more stable than the other linux distros. But why 32 Bit? Because I think 32 Bit OS is using less memory than the 64 Bit.

VPS Minimum Security Settings

What I do for the first time is add a new non-root user, and set BASH as its shell.

adduser --shell /bin/bash johndoe

Next, I’m gonna change the default SSH port that is 22 into a new number above 1024 and below 65535. Then I’ll disable root logins over SSH. In order to do that, we need to edit the sshd_config file located in /etc/ssh/sshd_config. I’m using pico as the text editor.

pico /etc/ssh/sshd_config

To change the port number, find this line:

Port 22345

To disable root logins, find this line:

PermitRootLogin no

Then restart the SSH service.

service ssh restart

Now, you need to logout from root, and re-login using new user that you just created before.

After we logged in as a normal user, and if you need a root privileges, you can use su command:

su -

Congratulations! You just finished the minimum security settings of your VPS.

Getting Updates for VPS from Repository Server

As root, open the sources.list file, located in /etc/apt/sources.list

pico /etc/apt/sources.list

Edit or replace all of the existing lines with these lines:

deb http://ftp.us.debian.org/debian squeeze main contrib non-free
deb http://ftp.us.debian.org/debian squeeze-updates main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free

Proceed the update.

apt-get update && apt-get upgrade -y

After the update process completed, I wanna change the default timezone of my VPS.

dpkg-reconfigure tzdata

Install vnc4server and web browser on VPS

This command will install an xserver, vnc4server and iceweasel browser also flash plugin.

apt-get install -y --no-install-recommends xserver-xorg-core xfonts-base xterm jwm menu vnc4server iceweasel flashplugin-nonfree

Now let’s try to run the vnc4server. You can also change the geometry to 1024×768, and depth to 24.

vnc4server -geometry 800x600 -depth 16

Since it’s the first time you’re running vnc4server, you will be asked for a password. That password will be used for accessing your desktop using VNC viewer.

Open your VNC viewer and connect to your VPS. I’m using RealVNC. Set the “VNC Server” to your VPS IP address and add :1, example: 192.168.100.25:1

To stop vnc4server, type this command:

vnc4server -kill :1

You may want to know how to run vnc server at startup / boot and also how to restart vnc server hourly using crontab.

What if I wanna run Firefox browser each time my VNC server is up? Sure you can. Just edit xstartup file located on your username VNC folder. If your username is root, then the xstartup file is in /root/.vnc/xstartup

pico /root/.vnc/xstartup

add new line:

firefox --display=:1 -private &

Download Firefox 3.6.28 and replace iceweasel as default web browser

In this example, I downloaded the Firefox into /root folder, and extract it into /opt folder. You can always change it if you want.

wget http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/3.6.28/linux-i686/en-US/firefox-3.6.28.tar.bz2 -O /root/firefox-3.6.28.tar.bz2 && cd /opt && tar xjvf /root/firefox-*

Edit the firefox script:

pico /usr/bin/firefox
  • --> comment line:
    #exec iceweasel "$@"
  • --> add new line:
    exec /opt/firefox/firefox "$@"
update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/firefox 100
update-alternatives --set x-www-browser /usr/bin/firefox

How to restart your VPS daily

Simply add a new cron job. Open your crontab:

crontab -e

Add this line:

59 23 * * * /sbin/shutdown -r now

That means, your machine will be rebooted everyday at 23:59.