Home > Articles > Operating Systems, Server > Solaris

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


OpenSSH offers a number of features to protect network connections between two hosts. There are choices of protocol, authentication method, port forwarding, user access, and network access. When setting up OpenSSH, you will have to make trade offs between security, ease of use, and legacy compatibility. The choices you make depend on local security policy.

Protocol Support

There are two major versions of the secure shell protocol: SSH1 and SSH2. SSH1 was the first protocol developed and has been replaced with SSH2. It is highly recommended that you disable the use of SSH1 since the protocol has been found to have several vulnerabilities including packet insertion attacks and password length determination. In sshd_config and ssh_config, set Protocol to 2, as follows.

# Protocol 2 only is recommended.
 Protocol 2

For legacy client and server support, allow SSH1 but set the default to SSH2, as follows.

# Enable legacy support but default is Protocol 2.
Protocol 2,1

Unfortunately, many legacy clients and servers only support SSH1. Consider upgrading legacy clients and servers to those that support SSH2. If you wish to audit installed base of ssh servers, consider using scanssh by Niels Provos. It is designed to scan a network and report the version strings of any ssh servers found. (You can also use ssh-keyscan and shell scripting to accomplish the same thing in a much less efficient manner.)

Network Access

By default, the OpenSSH server daemon listens to all network interfaces. For workstations and other systems where accessibility is desired on all interfaces, this is not a problem. For architectures where a single interface is dedicated to management or administration, it is preferable not to expose OpenSSH to the other networks. Limit network access with ListenAddress in sshd_config as shown here.

# Listen only on management network

To further narrow down what the server will listen to (for example, a specific address range or single host), use either a host-based firewall or a tool like tcpwrappers.


OpenSSH does support the use of TCP wrappers but support needs to be compiled into the server. Consult the build documentation of OpenSSH for information.

Connection Forwarding

OpenSSH can create a secure tunnel to provide some protection for insecure protocols. This is referred to as connection forwarding and only works for TCP-based connections. During connection forwarding, a local TCP port is opened and OpenSSH waits for a connection. When OpenSSH receives a connection, it forwards the data to the OpenSSH server on the other end. The server then sends the data to its final destination. Responses follow the same process, in reverse.


Data is protected only until it reaches the OpenSSH server. After that, it is handled the same as normal network traffic.

Connection forwarding is useful for protecting commonly used, noncryptographic protocols like IMAP, which is used for email. It can also be used to provide remote users with access to internal resources such as news, email, and web access. If policy is such that remote users are to be granted access to these resources, enable connection forwarding.

There are two caveats with connection forwarding. Firstly, connection forwarding is an all or nothing mechanism. Once forwarding is allowed, the client can forward any port to any location on the remote side. If this is an issue, consider using host-based firewalls on the OpenSSH server to limit connections. Secondly, because traffic that travels through connection forwarding is encrypted, neither a firewall, nor an intrusion detection system can detect when abnormal events occur. The OpenSSH server on the remote side is traffic agnostic. It does not know if data coming out is a normal IMAP request for a message or if it is buffer overflow exploit against the IMAP server. Plan firewall and intrusion detection sensors accordingly. Add the following to sshd_config to allow TCP forwarding.

# Server configuration
AllowTCPForwarding yes

An example of a client forwarding in ssh_config.

# client configuration
# Allow remote users access to an internal web server.
LocalForward 8080 http://www.corp.acme.com:80

Gateway Ports

Gateway ports work in conjunction with connection forwarding. Normally, connection forwarding allows only the local host to send data to the other side of a connection. By using a gateway port, you enable other machines to connect and forward data. In effect, gateway ports create a tunnel from one network to another network. This is highly risky and in general should always be disabled. For example, an user sitting in an airport connected over a 802.11b wireless link with gateway ports turned on and a local forward to an internal web server would allow everyone in the immediate vicinity access to the web server. Set the following in both sshd_config and ssh_config.

# Server and client configuration
GatewayPorts no

X Forwarding

OpenSSH can also securely tunnel X traffic. Because the X protocol travels in the clear, it is vulnerable to sniffing and hijacking. OpenSSH emulates an X server on the remote side and passes traffic back through the tunnel to the local client. In addition to its usefulness for remote users, this can also help decrease the potential for users to use xhost + to disable all access controls. Add the following lines to both sshd_config and ssh_config.

# Server and client configuration
X11Forwarding yes

The following is an example of the values of $DISPLAY on a local host and over an X forwarded tunnel.

host $ echo $DISPLAY
host $ ssh remotehost
user@remotehost's password:XXXXXXXX
remotehost $ echo $DISPLAY

User Access

Some sites require that a banner be displayed once users connect to a system, but before they log in. If this is required, set the banner to /etc/issue in sshd_config, as shown in the following example, so only one banner exists for the whole system.

Banner /etc/issue

The default login grace time is ten minutes. This value is too high. Consider reducing it in the sshd_config to thirty or sixty seconds as shown here.

LoginGraceTime 60

User access control lists can be specified in OpenSSH; however, no part of the Solaris OE honors this access control list (ACL). The two available options are to allow only specified users access, or to specifically deny a user access. The default is to allow anyone access. You can also specify access with group membership. Note that the groups options only apply to the primary group (the group listed in /etc/passwd). An example of both allow and deny ACLs in sshd_config appears as follows.

# Allow sysadmin staff
AllowGroups staff

# Or limit a particular user's access off a machine
DenyUsers kaw alex

By default, the root user can log in using OpenSSH. This is fine for systems without user accounts. However, disabling root logins and requiring administrators to use su to root is more secure and leaves an audit trail. If you have remote jobs that run as root, you can configure OpenSSH to only execute scripts. This requires the use of two-factor (key-based) authentication. If root logins are required at your site, only use key-based authentication as discussed later in this article. To set this up, add the following to sshd_config.

# Only add one of these settings.
# Forces sysadmins to su.
PermitRootLogin no
# If remote jobs require root priviledges.
PermitRootLogin forced-commands-only


OpenSSH supports multiple forms of authentication: the traditional login and password, two- factor (public-key-based), and host-based. Each method has different benefits. Password authentication fits well in existing structures. Two-factor authentication offers improved security, although with higher maintenance costs. Host-based authentication provides the most convenience, although it is extremely unsafe and easily abused.

Password authentication is the most common way for systems to authenticate users. The drawback to this method is that passwords can be shoulder-surfed, guessed with dictionaries, and sniffed in transit across the network. While OpenSSH protects passwords by encrypting them, this only prevents sniffing while they are in transit, and can't do anything to minimize the effects of other threats. To counter other threats, OpenSSH provides two-factor or key- based authentication.

Key-based authentication is a challenge and response system which is grounded in the mathematics of public-key cryptography. There are essentially two elements: a public key that resides on all servers the user will access, and a private key that only the user knows. The private key is additionally protected by a passphrase. This system is more secure than passwords alone because in addition to being based on a passphrase the user knows, it is also based on something the user has in their possession, the private key.

The system works roughly as follows. OpenSSH generates a key pair, stores the public key on the OpenSSH server, and leaves an encrypted version of the private key on the user's machine with a passphrase. When the user connects to the server, OpenSSH prompts the user for a passphrase to decrypt the private key. The OpenSSH client and server then go through a challenge and response to prove that the two keys are related. If the server agrees that user really does have the private key, it grants the user access. The private key is never stored on the server or transmitted to it, and the public key is useless without the private key, and vice versa. For a system to be subverted (leaving out program flaws like bugs), someone would have to acquire a copy of the private key and the passphrase.

Because private keys are often stored on NFS home directories, good passphrases are critical to the success of this approach. Examples of bad phrases might include simple sentences with no punctuation and no capitalization, or extremely common phrases like "to be or not to be." Examples of good phrases include phrases or words the user can easily remember and won't write down. If a user looses a passphrase, you will need to generate a new key pair, as a passphrase cannot be recovered. Further, passphrases tend to be resistant to shoulder surfing due to their length.

Host-based authentication trusts a connection based on where it comes from. This is very unsafe and easily abused. Rlogin and rsh also use this method of authentication as denoted by their dependence on .rhosts files.

It is recommended that sites disable any semblance of host-based authentication. Sites that support a large number of internal users should consider staying with passwords to reduce training costs. Sites with remote users and sites that need to automate jobs should consider using key-based authentication. Add the following to sshd_config for the preceding recommendations.

# Disable unsafe hosts based authentication
HostbasedAuthentication no
RhostsAuthentication no
IgnoreRhosts yes
# Empty passwords are trivial to guess
PermitEmptyPasswords no
# For internal servers, passwords ok. Bastion hosts - no.
PasswordAuthentication yes
# For remote access, automated jobs, and advanced users
PubkeyAuthentication yes

  • + Share This
  • 🔖 Save To Your Account