Readers will learn how to add SSH keys to UniFi devices through the UniFi Network Controller.
- Applicable to the latest UniFi Controller versions.
- See the How to Establish a Connection Using SSH article for more information on how to access UniFi devices using SSH.
Table of Contents
- Generating an SSH Key on Windows using PuTTYgen
- Generating an SSH Key on macOS/Linux using ssh-keygen
- Adding the SSH Key to the UniFi Controller
- Related Articles
Generating an SSH Key on Windows using PuTTYgen
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.
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
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.
4. View the contents of the public SSH key file. Assuming the file name was not changed:
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
1. When using the Classic Web UI, navigate to the 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
SSH key generated with ssh-keygen
6. Select Add to add the new SSH key and apply the changes.