UniFi - Adding SSH Keys to UniFi Devices

UniFi makes it simple for administrators to add SSH keys to UniFi Devices. If you are just looking to enable SSH or establish an SSH connection with UniFi devices, please see here.

Instructions

Before you begin: Adding SSH keys to UniFi devices through the UniFi Network application should only be done by advanced system administrators familiar with SSH.

Instructions for each operating system are found below:

Windows

Linux

macOS

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.
    1. Note: Never share the private key file or its contents.
  5. Copy the complete contents of the SSH key file from the box labeled Public key for pasting into OpenSSH authorized_keys file. The SSH key starts with ssh-rsa and ends with == rsa-key-<date>, for example:
    ssh-rsa AbCdEfGh1234AbCdEfGh== rsa-key-20200911
  6. Add the key to UniFi Network by navigating to Settings > System > Advanced > Device Authentication > SSH Keys. 
  1. Open the Linux Terminal.
  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.
    1. Note: 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
  6. Add the key to UniFi Network by navigating to Settings > System > Advanced > Device Authentication > SSH Keys. 
  1. Open the macOS Terminal, located in Finder > Applications > Utilities.
  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.
    1. Note: 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
  6. Add the key to UniFi Network by navigating to Settings > System > Advanced > Device Authentication > SSH Keys. 
Was this article helpful?
143 out of 341 found this helpful