Difference between revisions of "Enabling SSH Logins To The UDM"
(Created page with "==SSH In The Admin UI== The UDM has two different SSH configurations, one that allows login to the UDM itself and another that the UDM provisions onto the other UniFi network...") |
m |
||
Line 3: | Line 3: | ||
The UDM has two different SSH configurations, one that allows login to the UDM itself and another that the UDM provisions onto the other UniFi network devices it adopts so that you can directly login to them. | The UDM has two different SSH configurations, one that allows login to the UDM itself and another that the UDM provisions onto the other UniFi network devices it adopts so that you can directly login to them. | ||
− | The one that allows logins to the UDM itself only supports userid/password authentication out of the box. We want to add public key authentication to that so that we don't have to enter a password every time we log in. But first we must enable the service through the admin UI: | + | The one that allows logins to the UDM itself only supports userid/password authentication out of the box. We want to add public key authentication to that so that we don't have to enter a password every time we log in. But first we must enable the SSH service through the admin UI: |
# Click through "Settings" -> "Advanced" from the bottom of the main UI window | # Click through "Settings" -> "Advanced" from the bottom of the main UI window |
Revision as of 13:46, 19 January 2021
SSH In The Admin UI
The UDM has two different SSH configurations, one that allows login to the UDM itself and another that the UDM provisions onto the other UniFi network devices it adopts so that you can directly login to them.
The one that allows logins to the UDM itself only supports userid/password authentication out of the box. We want to add public key authentication to that so that we don't have to enter a password every time we log in. But first we must enable the SSH service through the admin UI:
- Click through "Settings" -> "Advanced" from the bottom of the main UI window
- Turn on "SSH" and set a password. SSH login for the "root" user is now possible by entering a password.
The other SSH configuration that the UDM uses to provision other UniFi devices on the network is set up, using the "New Settings" menus, under "Network" -> "Settings" -> "System Settings" -> "Controller Configuration" -> "Device SSH Authentication". A userid, password and SSL keys can be setup here. These will be provisioned to each UniFi networking device on the network that this controller adopts.
Setting A Persistent SSH Key For The root User
Setting the login key requires that we add our SSH key to the /root/.ssh/authorized_keys
file. The trouble is that this file gets wiped and restored every time the UDM reboots, causing it to lose the changes we make. We will use the on-boot-script utility from the udm-utilities package on GitHub to overcome this issue. It will restore our SSH key to the /root/.ssh/authorized_keys
each time the UDM reboots.
As root on the UDM do:
# unifi-os shell # curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.2_all.deb -o udm-boot_1.0.2_all.deb # dpkg -i udm-boot_1.0.2_all.deb # exit
Copy the 15-add-root-ssh-key.sh file to /mnt/data/on-boot.d/
and put the public SSH key into it. Either run that script manually, or reboot the UDM to populate the /root/.ssh/authorized_keys
file with the SSH key.
Logons from the client using the default SSH configuration will fail. To fix this, add a stanza to the ~/.ssh/config
file, setting udm-hostname to be the host name or IP address that you use with the ssh command:
Host udm-hostname User root PubkeyAcceptedKeyTypes +ssh-rsa