Improving instance security using two-factor authentication with Duo (2FA)

Modified: 17 May 2023 01:14 UTC

In addition to protecting your Triton cloud account in the portal with two-factor authentication, you can also protect your instances with two-factor authentication when connecting to your instance through SSH. Using Duo, verification will be sent to your mobile device. This document describes how to add 2nd factor authentication to SmartOS using the Duo PAM module.

What is two-factor authentication for SSH and how does it work on SmartOS?

SmartOS libpam allows adding additional methods of verification when connecting using SSH. The default method of verifying identity for SSH is using a public and private key pair. This allows for passwordless authentication as SSH keys are much harder to guess than passwords and are less susceptible to brute force attacks. Private keys can be further protected with a passphrase so that if your private key is compromised or stolen, it cannot be used without knowing the passphrase. Two-factor authentication does not require the use of keys, you can use a normal password in addition to a one-time-password, however as stated earlier passwords are not as secure as using keys.

Duo PAM Library for two-factor authentication

Using the Duo PAM library can add another layer of security to your instance. The following setup method will use the default key verification method as well as adding another factor using one-time-passwords (OTP) or push notifications generated through the Duo application. When using Duo for two-factor authentication, a Duo account is required and the instance must be able to contact the Duo servers.

Installing Duo on SmartOS using pkgsrc and configuration for SSH/PAM (root user)

The Duo library is available in pkgsrc on SmartOS. The command pkgin install duo-unix-compat32-1.0 will install the Duo library. After installation via pkgsrc the following steps need to be taken to configure SSH to use Duo authentication: