×

UniFi - Adding SSH Keys to UniFi Devices

Overview

Readers will learn how to add SSH keys to UniFi devices through the UniFi Network Controller. 

NOTES & REQUIREMENTS:

Table of Contents

  1. Generating an SSH Key on Windows using PuTTYgen
  2. Generating an SSH Key on macOS/Linux using ssh-keygen
  3. Adding the SSH Key to the UniFi Controller
  4. Related Articles

windows.png  Generating an SSH Key on Windows using PuTTYgen

NOTE: On Windows 10, it is also possible to use WSL to generate SSH keys. In this case, the commands will be identical to the macOS/Linux steps below.

1. Download and install the full PuTTY installer package or the standalone PuTTYgen binary.

2. Open Putty Key Generator (PuTTYgen) to generate a new SSH key. 

3. Select RSA with a key size of 2048 and select Generate.

4. Save the public key and private key in a secure location after they have been generated.

ATTENTION: Never share the private key file or its contents.

5. Copy the complete contents of the SSH key file from the Public key for pasting into OpenSSH authorized_keys file box to your clipboard. The SSH key starts with ssh-rsa and ends with == rsa-key-<date>, for example:

ssh-rsa AbCdEfGh1234AbCdEfGh== rsa-key-20200911

macos.png  Generating an SSH Key on macOS/Linux using ssh-keygen

1. Open the macOS/Linux Terminal through the Launcher or by navigating to the Finder > Applications > Utilities section (macOS).

2. Use the ssh-keygen command to generate a new SSH Key:

ssh-keygen -t rsa

3. Either use the default file name or enter a file name of your choice and optionally add a passphrase.

ATTENTION: Never share the private key file or its contents.

4. View the contents of the public SSH key file. Assuming the file name was not changed:

cat .ssh/id_rsa.pub

5. Copy the complete contents of the SSH key file from the Terminal window to your clipboard. The SSH key starts with ssh-rsa and ends with username@machine, for example:

ssh-rsa AbCdEfGh1234AbCdEfGh admin@computer

Adding the SSH Key to the UniFi Controller

GUI: Access the UniFi Controller Web UI.

1. When using the Classic Web UI, navigate to the  settings.png  Settings > Sites > Services section and check the Enable advanced features box.

2. Apply the settings.

3. In the same section, scroll down to Device Authentication and check the Enable SSH authentication box.

4. Select +ADD NEW SSH KEY to add a new SSH key.

5. Enter a name of your choosing and paste the previously copied contents of the SSH key file. For example (key length shortened):

SSH key generated with PuTTYgen

puttygen.png

SSH key generated with ssh-keygen

ssh-keygen.png

6. Select Add to add the new SSH key and apply the changes.

Related Articles

Intro to Networking - How to Establish a Connection Using SSH

Was this article helpful?
12 out of 30 found this helpful
Can't find what you're looking for?
Visit our worldwide community of Ubiquiti experts for more answers
Visit the Ubiquiti Community