Resources for “A Server (Almost) of Your Own”

George Belotsky

Issue #152, December 2006

Some of the code was formatted incorrectly in George Belotsky's “A Server (Almost) of Your Own” in our December 2006 issue. For the corrected version of the article, please see: /article/8337

This page contains updates to the article, as well as some important security information for running your VPS.

Thanks again to Sean Reifschneider, Evelyn Mitchell and the rest of the Tummy.com crew for their very helpful suggestions and for letting me use their equipment once more, to test the updates presented here.

While you can still get a VPS based on Fedora Core 3, the system used for the article, you may want something more recent. For example, CentOS 4.4, which derives from Red Hat Enterprise Linux, requires only minor deviations from the directions in the article text. The CentOS project home page is at www.centos.org.

The following notes update the instructions from Fedora Core 3 to CentOS 4.4. Tummy.com offers both variants, as well as several others, including Ubuntu and Debian.

Firewall Settings

When you configure the firewall with system-config-securitylevel-tui, the text-based GUI may not render correctly in your terminal. If this makes it difficult to use the application, try running the terminal program with the UTF-8 character encoding.

For example, xterm -u8 should launch a UTF-8 xterm. In gnome-terminal, select Terminal→Set Character Encoding→Unicode (UTF-8) from the menu bar in order to enable UTF-8.

Postfix Mail Server

You will need to update the last two lines of Listing 1, as the Postfix mail server version has changed. Here is the new code.

sample_directory = /usr/share/doc/postfix-2.2.10/samples

readme_directory = /usr/share/doc/postfix-2.2.10/README_FILES

Note that the sample_directory parameter is obsolete since version 2.1 of Postfix.

When testing your mail server by telnetting to port 25, you may find it blocked by your local ISP. Many DSL and cable providers do this now.

It is quite simple to configure Postfix so it listens on a non-standard port, such as 10025, in addition to port 25. Edit the file /etc/postfix/master.cf. Note that this is not the main.cf file that you worked with in Listing 1. Near the top, you will find the following lines:

# =======================================================================
# service  type  private  unpriv  chroot  wakeup   maxproc  command + args
#                (yes)    (yes)   (yes)   (never)  (100)
# =======================================================================
      smtp   inet    n        -       n       -       -       smtpd

Add the following line, after the “smtp” line.

10025     inet  n       -       n       -       -       smtpd

Next, restart Postfix: /etc/init.d/postfix restart.

Finally, re-run the system-config-securitylevel-tui utility as described in the article. On the “Customize” screen, add 10025 to the “Other ports” text box. If there are other entries in this textbox, scroll to the last one, add a space, and make the new, additional entry. “OK” your changes and restart iptables, as discussed in the article.

From your workstation, you can now telnet to port 10025 on your VPS instead of port 25, to carry out the tests described in the article. After sending these hand-generated test messages, remember to check the Spam folder at the receiving end. Unusual formatting, such as the lack of a subject, of these e-mail messages may cause them to be flagged as junk.

While on the subject of spam, the problem is getting worse, as you probably know. Listing 1 in the article uses luser_relay to deliver mail for unknown recipients to a specific user on the system. This is very convenient, because you can just invent e-mail addresses, and they will work without any configuration changes.

Unfortunately, luser_relay may expose you to a lot more spam. If this happens, you will need to add all your legitimate addresses to /etc/aliases and comment out luser_relay. The article text describes how to work with /etc/aliases.

Dovecot for POP3 and IMAP

When setting up Dovecot to provide POP3 and IMAP service, the newer configuration file may look a little different.

In CentOS 4.4, the default configuration has the protocols line commented out. It is also changed from what appears in the article text:

#protocols = imap imaps

Do not be confused by these minor differences; just add the code as described in the article: protocols = pop3 imap in this case. Dovecot will still work correctly.

Reading and Sending Mail

There are no substantial changes—only the dialog boxes may look slightly different in later versions of Mozilla Thunderbird. There is also a “Description” field in the SMTP server dialog, which you may leave blank.

If you are using the mutt-based solution described in the article, no modifications are required.

Web-based Mail

When configuring SquirrelMail, it is possible that the Web server is already running. In this case, starting it, as described in the article, will have no effect.

Try restarting the Web server instead, especially if you are having trouble opening SquirrelMail's pages in your browser:

/etc/init.d/httpd restart

You may use the restart command even if the server is not running. In this case, the attempt to stop the server will fail, but the subsequent start operation will proceed normally.

SSH Security

Extremely broad Internet sweeps that look for SSH access at many IP addresses seem to have become widespread in late 2004. Here are some insightful descriptions of the problem, and several solutions:

One relatively simple change that you can implement quickly is moving your SSH dæmon, sshd, to a nonstandard port. This measure—although weak from a theoretical security perspective—is currently very effective in deterring the generic SSH sweeps that do not specifically target your system.

Carefully perform the following steps, in the order given:

  1. Modify your firewall settings to permit access on a nonstandard port, such as 2222.

  2. Restart iptables: /etc/init.d/iptables restart.

  3. Add the directive “Port 2222” to /etc/ssh/sshd_config.

  4. Restart sshd: /etc/init.d/sshd restart. Do not log out from the server. If you are unable to carry out step 5 below, you may still be able to double-check the configuration and make changes from your original SSH session. Of course, your VPS hosting company should help if you completely lock yourself out.

  5. Open another terminal, and log in to your VPS with ssh -p 2222 root@MY.VPS.IP.ADDRESS. Note that from now on, you will always need to specify this nonstandard port number when you access your VPS using SSH. Alternatively, you can edit the .ssh/config file in your home directory, and configure the nonstandard port there—see the SSH documentation for details. You can create this file if it does not currently exist.

  6. Optional step. Modify your firewall settings again, and disable SSH access on port 22. If you are using system-config-securitylevel-tui, this is done by unchecking the “SSH” checkbox on the “Customize” screen.

Additional Information

The Postfix home page, at www.postfix.org, has lots of information about the Postfix MTA. You can also read an excellent introduction to Postfix at www.onlamp.com/pub/a/bsd/2003/08/21/postfix.html. Note that this article covers an earlier version of the server, so there are some configuration differences from the current version.

Finally, Wikipedia has a brief but very insightful description of e-mail terminology, at en.wikipedia.org/wiki/Mail_transfer_agent.