Home > Articles > Security > Network Security

  • Print
  • + Share This
Like this article? We recommend

Relevant Settings

The information in Table 1 is derived from the actual sshd_conf documentation. If you find something really puzzling, review the documents again. Buy a book. The OpenSSH community is pretty helpful if you have a big problem or worthy suggestion. And don’t forget those hundreds of hits in Safari waiting for you to activate your free trial period.

Table 1 OpenSSH server security settings and possible values.

Directive

Security Importance

Port 22

Running a service on a nonstandard port is part of the "security through obscurity" game, which seldom works with today’s sophisticated scanning engines. Some people have implemented a configuration called "port-knocking," something that requires a separate article. Others ensure that OpenSSH is compiled with TCP wrappers support. This strategy allows for basic address filtering of unwanted hosts. (Want an article on TCP wrappers and what this feature can bring you? Respond below.)

#Protocol 2,1

Protocol 1 seems to have some security risks tied to it. Most sources I read recommend sticking to Protocol 2 for most SSH installations.

# HostKey for protocol version X

See this as a flashing sign. You must protect the integrity of these keys. There is no easy revocation process, and implementing a new key will have lots of SSH clients complaining about the new signature. Your help desk will love you if you keep the updates to organized, communicated changes.

# Lifetime and size of ephemeral version 1 server key

#KeyRegenerationInterval 1h

#ServerKeyBits 768

Still going to use Protocol 1, eh? Right now, 1024 key size seems to be a value that many sources recommended. You must keep track of cryptographic happenings yourself and adjust the key bits up as needed.

# Logging

# obsoletes QuietMode and FascistLogging

#SyslogFacility AUTH

#LogLevel INFO

You must turn on logging. From there, the recommended values get fuzzy. Try the defaults and check the logs. Got enough for an investigation? If not, see the sshd_conf man page for values and their meanings. Servers set to debug levels of logging might indicate that an intruder is analyzing your sshd design closely.

# Authentication:

#LoginGraceTime 2m

#PermitRootLogin yes

#StrictModes yes

#MaxAuthTries 6

These settings generate a lot of discussion among experts. Should you permit a direct login as root? Should you require people to log in with basic accounts and then invoke root privilege as needed? I’m going to invite flames by stating that it’s okay to permit root login under certain conditions (to be listed in any rebuttal to said flames). I also believe that StrictModes is important. If a user opens his or her home directory (o +w), all SSH files are open to hackers—tantamount to loaning your system account to anyone else in the world. StrictModes keeps sshd from accepting logins from poorly secured account settings.

#RSAAuthentication yes

#PubkeyAuthentication yes

#AuthorizedKeysFile .ssh/authorized_keys

RSA authentication is used with Protocol 1 only, so I won’t cover it in this article. PubkeyAuthentication is used to enable public key authentication. Part 1 of this series specifies the potential shortcomings of digital key authentication, but overall I strongly prefer it to passwords—given sane credential handling practices in the field. AuthorizedKeysFile is another important setting. Users can place their public key(s) into a file and thereby enable PubkeyAuthentication. Note the plural: Users can create and misplace and undersecure all the key pairs they choose to use. Your goal is to select a reasonably secure file choice and location for the key pair(s). Something like the /pub directory in /var/ftp might be a bad choice....

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts

#RhostsRSAAuthentication no

# similar for protocol version 2

#HostbasedAuthentication no

Again, RSA authentication is used with Protocol 1 only, and so I’ll duck out of covering it here. Host-based authentication attempts to wed ~/.rhosts or /etc/hosts.equiv with digital key authentication. The default is no, and seemingly for good reason. There are many attacks (and attack tools) that love to attack .rhosts and hosts.equiv. Leave it off.

# Change to yes if you don’t trust ~/.ssh/known_hosts for

# RhostsRSAAuthentication and HostbasedAuthentication

#IgnoreUserKnownHosts no

# Don’t read the user’s ~/.rhosts and ~/.shosts files

#IgnoreRhosts yes

I believe that most users will set home directory permissions to 777 if an attacker asks nicely enough. I believe that they’ll use Yahoo! mail to distribute the most confidential information—and unencrypted at that—if a stranger insinuates a big order. I don’t that believe you should trust user-configured ~/.rhosts or their known_hosts files. I believe that UserKnownHosts and user .rshosts and .shosts should be ignored. Think otherwise? Respond below.

# To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes

#PermitEmptyPasswords no

Tough choices, indeed. Passwords suck, but we still use them. They’re configured by users, using predictable values. But until we have easier methods to generate, distribute, and revoke digital keys securely, I think we still need to configure SSH to use passwords. I think you shouldn’t permit empty passwords. Even if you have a service account with a truly secure "forced command," enabling empty passwords will enable it for other users.

# Change to no to disable s/key passwords

#ChallengeResponseAuthentication yes

# Kerberos options

#KerberosAuthentication no

#KerberosOrLocalPasswd yes

#KerberosTicketCleanup yes

#KerberosGetAFSToken no

# GSSAPI options

#GSSAPIAuthentication no

#GSSAPICleanupCredentials yes

#UsePAM no

OpenSSH supports some sophisticated authentication technologies. If your organization uses s/key, Kerberos, or the Generic Security Services Application Program Interface (GSSAPI), test them and then enable them here. PAM is cool; get a book on using it with SSH, however. There’s a lot of complexity, some of which is hinted at strongly in the sshd_conf comments.

#AllowTcpForwarding yes

#GatewayPorts no

Allow forwarding? Provide an open gateway to all? Do you want your sshd to act as a VPN gateway? If you feel you have the skills needed to understand and support/secure such a configuration, enable it. Be prepared to answer for your decision, however.

#UsePrivilegeSeparation yes

Upon successful authentication, sshd forks a process that runs as the user account. Use this setting to slow many privilege-escalation attacks.

#UseDNS yes

I’m going to vote no here. Try it with a yes. If you find that people can’t log in, thank some ISP’s DNS tables. Some don’t have accurate PTR records that resolve successfully to their A records. Even with accurate DNS, what security is provided? I personally believe in authenticating people, not devices and locations. Internet connection-sharing technologies and firewalls that translate outbound traffic to split DNS designs just make it tough to draw too much specific information on a device and its reported IP address.

#PermitTunnel no

See my comments on forwarding. You’re joking, right?

# no default banner path

#Banner /some/path

Security folklore has it that some hacker wasn’t convicted of his/her crimes because of a welcome banner that actually welcomed the users. Anyone have specifics on this? Is it truly important to have a banner that warns users that they’re being monitored? If so, here’s where you specify a banner file.

Clearly, the SSH server has many intricate and useful security settings that can be applied in many ways. Your distribution may have many more—both settings, and ways to apply them. Feel free to plug them into the final row of the table and respond below.

  • + Share This
  • 🔖 Save To Your Account