Create an Ubuntu 10.04 Xen Guest Image via Debootstrap
August 24, 2010 by David · Leave a Comment
This is a lot easier than everyone makes it out to be. I’m doing this post because I was looking around at other tutorials and saw crap like having to hack scripts from Karmic and stuff like that. What the hell. Anyway, here’s a step-by-step guide to create a Lucid Lynx Xen-ready image (pvgrub-ready) using debootstrap. Debootstrap is a Debian/Ubuntu program but I believe that there is a way to install it on Fedora/Centos systems as well (at the time of writing I haven’t really looked, though).
Before we start, a quick disclaimer: while these steps will create a basic, functioning Lucid image, I’m not making any claims about it working 100% in every Xen environment. Like with any DomU template, you’ll need to test it thoroughly for your Xen environment before deploying, especially in a production environment. Now, lets begin:
Reset MySQL Root Password
June 6, 2010 by David · Leave a Comment
Forgetting the root password for a MySQL server probably happens at least once in a sys admin’s life. It must also be really embarrassing if the sys admin is also the DB admin, heh. MySQL passwords are encrypted by default, so your only real option is to reset the root password. It’s a straight-forward process but does require you to shut down MySQL.
What is a VPS
April 24, 2010 by David · Leave a Comment
A part of my job consists of building and managing VPS’s. They’re pretty hot right now (have been for a long time), however whenever I bring them up during discussions about webhosting, people just stare at me blankly. So here is a quick, layman’s-terms guide to what a VPS is and why webmasters should be interested in them.
How To Install Denyhosts on Centos
Denyhosts is a lovely python script that can help stop SSH bruteforce attacks. It scans your SSH logs and bans IPs that fail too many login attempts. While it is a staple on Debian/Ubuntu servers, it isn’t in the main Centos repositories. Fear not! Here is how to get it installed on a Centos box.
Setting Up Domains on Your Computer For Development Work
February 2, 2010 by David · Leave a Comment
I, like most people who like to test out new website applications/scripts or do some personal dev work, have a webserver installed on my computer. A grumbling I’ve heard often (most recently was last night, at the time of writing) is that they always have to have the script in a subdirectory, eg localhost/blahblah. Sure, they say, you can have your own domains, but only if you set up a DNS server. Which they don’t want to maintain.
Uh…. no you don’t. Just use your hosts file. How do you think your computer knows how to resolve localhost anyway? This little file is often overlooked, which is a shame. Just slap the domains in there and you’ll be able to host multiple sites on your computer (obviously you’ll need to configure the webserver to handle the domains). On Linux, the file is usually /etc/hosts, on Windows it’s C:\windows\system32\drivers\etc\hosts and on the Mac (Mac OS 10.2 and later) it’s /private/etc/hosts. They all follow the same format ([ip address] [domain name], eg 127.0.0.1 localhost).
Once edited, the domain will start resolving immediately. Trust me, it’ll work. Yeah, DNS is more feature-full, etc, etc, however for purely internal use the humble hosts file is still the best way to do things.
How To Log Subject Lines in Postfix
December 10, 2009 by David · Leave a Comment
By default, Postfix doesn’t log the subject lines of emails that it handles. There’s nothing wrong with this, however sometimes a user will want to know if an email came in (or was sent), and you’ll almost never have the message ID on hand to search for.
Luckily, Postfix does allow you to log warning messages for subject lines, and so we’ll use this to simply log a warning message for any subject line. It’s a bit of a ‘hack’, but works and doesn’t cause any problems (Postfix doesn’t block or alter the emails).
Firstly, edit the main.cf file and add the following line:
header_checks = regexp:/etc/postfix/header_checks
Next, create the /etc/postfix/header_checks file and add the following line:
/^subject:/ WARN
Reload/restart Postfix and send a test message. You’ll see something like the following in your logs:
Dec 10 10:57:01 localhost postfix/cleanup[22492]: 2290326720: warning: header subject: test email from localhost[127.0.0.1]; from= to= proto=SMTP helo=
Notice the “warning: header subject” bit. Now, every subject line will be logged :) It makes life a lot easier when doing email troubleshooting on a mail server.
SSH in Ubuntu OpenVZ Doesn’t Log to Auth.log File
I have a couple of Ubuntu 8.04 OpenVZ VPS’s, and I use the Deny Hosts script to block hackers trying to bruteforce SSH. However, the other day I noticed two files in /var/ on one of my VPS’s: logauth.log and logmail.err. Logauth.log was sitting at 105 megabytes! Not only was the info being logged to the wrong file, but the log wouldn’t be rotated (meaning that it would eventually become so bloated that it’d take forever to read).
As quite a few of my VPS’s were affected, I guess there’s a bug with some of the OpenVZ Ubuntu 8.04 images where SSH logins (and mail errors) are logged to the wrong file. Easy enough to fix – just edit /etc/syslog.conf and change any instance of /var/logauth.log to read /var/log/auth.log. While we’re at it, change /var/logmail.err Instance to say /var/log/mail.err.
Restarting sysklogd should load up the new values, but if you want to be paranoid I suppose you could just reboot the VPS (shouldn’t be necessary, but if you do rather use the hosting company’s control panel to do it)
Setting Up Sarg Correctly in Ubuntu
October 12, 2009 by David · Leave a Comment
The annoying thing about Ubuntu’s version of Sarg is that the cronjobs used to generate the reports are buggy – the weekly and monthly jobs only show some of the days :( Here is how I fix it. It’s not difficult at all, really, as you’re only modifying the contents of 4 files and removing a now-redundant one :)
Read more
Block Attachments in Postfix
September 27, 2009 by David · Leave a Comment
One of our clients requested that we block specific email attachments that come in – their large network was starting to suffer under the storm of non-work emails flying around the company – funny video clips, songs, etc, etc. Not only that, several gullible people had infected their PCs with viruses and malware.
Luckily, blocking specific mail attachments in Postfix is pretty straightforward and only takes a minute or two to set up.
Read more
Make Ubuntu Start Up Faster on Multi-Core Computers
September 27, 2009 by David · Leave a Comment
This is a nice quick one. I run an Ubuntu quad-core at home and was looking to find a way to get it to start up faster by making better use of the multiple cores. So, I was looking through /etc/init.d/rc, which is a config file for the program that handles the startup and shutdown of daemons on an Ubuntu box, and found this line:
Read more