Tuesday, June 7, 2011

How should a server be setup?

After recently acquiring a $75 tower, with reasonable specs, it has come to my attention that setting up a home server should have several steps that are a must. The last box died, in most part due to the age of the 15GB HDD. But Ubuntu was able to run and for a time, there was a nice little server running on it - 1 GHz, 256MB RAM (the 512 I put in wasn't detected...). After wiping the Windoze system and doing a clean install of Ubuntu 11.04 via network, I was able to get a LAMP installation running (but not utilising MySQL or PHP as these are both foreign to me), a Samba file sharing thingo, as well as installed and shared my Canon printer :).

Now, the guy I bought the $75 box from (3 GHz, 1GB RAM, 80GB HDD) suggested to use a USB stick to store important files. And while I do agree to some extent, I really just wanted to learn how to get a server going...hehehe. There may well be some extra benefits in the long run from having a file system that is accessible over the internet, however one does need to be weary of security issues and also the possibility that things might not do what you want them do - it's a learning process. With that in mind, I think Ubuntu Linux makes a very good distribution to get a server working.

Below, is a short list which is MY recommendations (and what I have done just recently) for what you should do/install after you have put an awesome distro of Linux on your box that has been sitting in the corner doing nothing for the last 4 years. My final message is as above: security is paramount. I'm not talking about physical security, although that may be important depending on which neighborhood you live in, but rather internet security. Call me paranoid, call me what you will, but there's no point setting up a server if other people are going to be able to get at it...unless you want them to of course.

Here's my list:
1) Configure sshd_config on the server so you can access it safely (in progress)
2) Setup printer
3) Move your web files to /var/www
4) Setup Samba

Here's my list - the detailed version
1) Configure sshd_config on the server so you can access it safely (in progress)
* Change the port in which SSH will listen. 22 is the default port so if you change it, unwanted guests will take longer to find your server.
* Disable root access. Allow only specific user/s, but never an account with root access.
* Setup SSH access via a public/private key. See Ubuntu Docs for more details and how to make one. Note: if after using this method and transferring the key to the server computer, you may find that the key fails to authenticate. This may be because you may not have added the ssh-server-address-thing (?) to your system. Run this command on the client computer (the computer in which you are accessing the server from), for some reason it is not mentioned in Ubuntu Docs:
ssh-add

2) Setup printer
* Make sure CUPS is up to date and all package dependencies have been met
* For my Canon PIXMA, see older posts
* If something isn't working, try turning the printer off and then on again, seems to do the trick

3) Move your web files to /var/www
* Maybe it's bad practise, but I've been getting into the habit of using /var/www as my LAMP root directory - it's the default directory anyway and I think it's safe
* If you wish to make directories that are accessible via internet, then you have to give the folder guest access. Just use chmod and chown to do this.
* I guess this is essentially how I set up my webserver. Not very flash bang and yes, update my website is one thing I need to do...

4) Setup Samba
* Only useful if you want to access your files over different OSes
* Or, if you don't like using SSH - which I kinda like...
* See next post for details

Things worth looking into:
* Logging break-in attempts: not sure how to do this but need an easier way than reading the /var/log/auth.log manually...

No comments:

Post a Comment