2022-06-21 15:49:32 +03:00
# UDM Persistence SSH Keys
2022-02-12 23:11:35 +02:00
## Persistence on Reboot
2022-04-23 22:01:59 +03:00
This script need to run every time the system is rebooted since the ** /root/.ssh/authorized_keys** overwrites every boot.
2022-06-25 09:20:50 +03:00
This can be accomplished with a boot script. Flow this guide: [UDM / UDMPro Boot Script ](https://github.com/unifi-utilities/unifios-utilities/tree/main/on-boot-script )
2022-02-12 23:14:24 +02:00
2022-02-12 23:25:15 +02:00
## Compatibility
2022-07-23 19:16:50 +03:00
- Tested on [UDM PRO][amz-udm-pro-url]
2022-04-23 22:01:59 +03:00
- UDM Pro doesn't support **ed25519** SSH Keys
2022-02-12 23:25:15 +02:00
2022-12-18 12:02:11 +01:00
2022-02-12 23:14:24 +02:00
## Installation
2022-02-12 23:25:15 +02:00
The script was tested on UDM PRO
2022-12-18 12:02:47 +01:00
(!) Depending on firmware your `$DATA_DIR` will be `/mnt/data` (Firmware 1.x) or `/data` (Firmware 2.x and 3.x)
2022-12-18 12:02:11 +01:00
2022-07-23 16:53:21 +03:00
```shell
2022-09-30 16:29:01 +03:00
curl -s https://raw.githubusercontent.com/fire1ce/UDM-Persistent-SSH-Keys/main/install.sh | sh
2022-02-12 23:25:15 +02:00
```
Add you public RSA keys to:
2022-07-23 16:53:21 +03:00
```shell
2022-12-18 12:02:11 +01:00
$DATA_DIR/ssh/authorized_keys
2022-02-12 23:25:15 +02:00
```
## Uninstall
Delete the 99-ssh-keys.sh file
2022-07-23 16:53:21 +03:00
```shell
2022-12-18 12:02:11 +01:00
rm -rf $DATA_DIR/on_boot.d/99-ssh-keys.sh
2022-02-12 23:25:15 +02:00
```
Delete your authorized_keys file
2022-07-23 16:53:21 +03:00
```shell
2022-12-18 12:02:11 +01:00
rm -rf $DATA_DIR/ssh/authorized_keys
2022-02-12 23:25:15 +02:00
```
## Usage
2022-12-18 12:02:11 +01:00
At boot the script with read the ** $DATA_DIR/ssh/authorized_keys** file and add the content to UDM's ** /root/.ssh/authorized_keys**
2022-02-12 23:14:24 +02:00
2022-02-12 23:25:15 +02:00
Manual run:
2022-02-12 23:14:24 +02:00
2022-07-23 16:53:21 +03:00
```shell
2022-12-18 12:02:11 +01:00
$DATA_DIR/on_boot.d/99-ssh-keys.sh
2022-02-12 23:25:15 +02:00
```
2022-07-23 19:16:50 +03:00
<!-- - - - -->
[amz-udm-pro-url]: https://amzn.to/3J4fezk 'Amazon Unifi UDM Pro'
<!-- - - - -->