This article provides the steps on how to add SSH keys to your UniFi Network devices. This implementation is done per-site and without the need for custom files placed on the UniFi Network Controller host.
Table of Contents
How to Add SSH Keys on Windows
Generate an SSH Key:
1. Install Putty (external link)
2. Open Putty Key Generator (Puttygen).
3. Select RSA with a key size of 2048.
4. Click Generate.
5. Move your cursor around the blank area above the "actions" section to generate a key.
6. After the key has generated save the public key and private key in a secure location on your PC. Remember to never share your private key!
Importing the private SSH key into PuTTY:
1. Enter a UniFi device IP or hostname under Session. For previously saved profiles go directly to step 2.
2. Navigate to Connection > SSH > Auth.
3. Click the "Browse" button under "Authentication parameters"
4. Locate the previously generated private key and click "Open".
5. Finally, click "Open" again to log into the remote server with key pair authentication.
How to Add SSH Keys on macOS/Linux
Generate an SSH Key:
1. Open a terminal on your machine and input the following:
ssh-keygen -t rsa
2. Hit enter to use the default file name or use a file name of your choice.
View the Public Key (needed for step 7 in the importing section):
3. Open a terminal on your machine and input the following:
NOTE: The filename may be different depending on what it was named.
Import the public SSH key into UniFi:
4. In the UniFi Network Controller navigate to Settings > Site > Device Authentication. If you can't see this section, please verify that you have enabled Advanced Features. See more.
5. Click "Add New SSH Key".
6. Name the key for future reference. It can be any name.
7. Copy the content from the "Public key" section of PuTTYGen.
8. Paste that into the "Key" section of the import window and click "Add".
User Tip: The key should start with 'ssh-rsa' and end with your "Key comment" (rsa-key-xxxxyyzz).
9. Hit enter or select "Apply Changes" in the Site menu.
10. The UniFi devices will be provisioned with the public key upon clicking "Apply Changes".