Serverwide Configuration

Chapter 5 provided a detailed discussion of sshd and how to configure its runtime behavior. Now let's determine which configuration options are most important for security.

SSH can provide a secure front door into your system, but don't forget to close the back doors. If your system allows access via the infamous r-commands, disable them. This means:

You might also consider disabling telnetd and other insecure avenues for logging in, permitting logins only via SSH.

We'll now discuss our recommended sshd_config settings for OpenSSH. We have omitted some keywords that aren't particularly security-related, such as PrintMotd, which simply prints a message after login. For any remaining keywords, use your judgment based on your system and needs.

We enable only public-key authentication. Password authentication is disabled because passwords can be stolen and used more easily than public keys. This is a fairly harsh restriction, so you might want to leave it enabled depending on your needs. Without password authentication, you have a "chicken and egg" problem: how do users upload their public keys securely the first time? As system administrator, you have to institute a process for this transfer: for example, users can generate keys on a client machine and then request that you install them on the server machine. Rhosts authentication is disabled because it can be spoofed. RhostsRSA authentication is disabled too, because overall it is a medium-security method and this configuration is on the side of higher security.

    # OpenSSH
    PubkeyAuthentication yes

    PasswordAuthentication no
    PermitEmptyPasswords no               Already disabled, but we're being paranoid
    RSAAuthentication no
    RhostsRSAAuthentication no
    HostbasedAuthentication no
    KerberosAuthentication no             Optional
    ChallengeResponseAuthentication no    Optional
    GSSAPIAuthentication no               Optional

We optionally disable Kerberos, keyboard-interactive, and GSSAPI authentication, even though they are quite secure, under the "keep it simple" principle: disable what you aren't using. Most SSH users aren't set up to use these techniques. Reenable them if your server needs to support them.

Although we've disabled hostbased authentication already, we still forbid sshd to use .rhosts files at all (just in case you reenable hostbased authentication):

    # OpenSSH
    IgnoreRhosts yes
    IgnoreRootRhosts yes

We now move to our recommended sshd2_config settings for Tectia. Again, we've omitted some keywords that are not security-related.



[140] The reliability of this restriction depends on the integrity of DNS. Unfortunately, due to the implementation of AllowHosts, restriction by IP address is no more secure. [5.5.1]