mirror of
				https://github.com/fire1ce/UDM-Persistent-SSH-Keys.git
				synced 2023-10-10 11:36:54 +00:00 
			
		
		
		
	20230222.1257
This commit is contained in:
		| @@ -1,5 +1,9 @@ | ||||
| # UDM Persistence SSH Keys | ||||
|  | ||||
| ## Changelog | ||||
|  | ||||
| - 2023-02-22 - Fixed support for UDM Pro Firmware 1.x and 2.x and 3.x - Must reinstall the script after upgrade from 1.x to 2.x | ||||
|  | ||||
| ## Persistence on Reboot | ||||
|  | ||||
| This script need to run every time the system is rebooted since the **/root/.ssh/authorized_keys** overwrites every boot.   | ||||
| @@ -10,7 +14,6 @@ This can be accomplished with a boot script. Flow this guide: [UDM / UDMPro Boot | ||||
| - Tested on [UDM PRO][amz-udm-pro-url] | ||||
| - UDM Pro doesn't support **ed25519** SSH Keys | ||||
|  | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
| The script was tested on UDM PRO | ||||
|   | ||||
							
								
								
									
										35
									
								
								install.sh
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								install.sh
									
									
									
									
									
								
							| @@ -3,23 +3,22 @@ | ||||
| # Get DataDir location | ||||
| DATA_DIR="/mnt/data" | ||||
| case "$(ubnt-device-info firmware || true)" in | ||||
|     1*) | ||||
|       DATA_DIR="/mnt/data" | ||||
|       ;; | ||||
|     2*) | ||||
|       DATA_DIR="/data" | ||||
|       ;; | ||||
|     3*) | ||||
|       DATA_DIR="/data" | ||||
|       ;; | ||||
|     *) | ||||
|       echo "ERROR: No persistent storage found." 1>&2 | ||||
|       exit 1 | ||||
|       ;; | ||||
|   esac | ||||
| 1*) | ||||
|   DATA_DIR="/mnt/data" | ||||
|   ;; | ||||
| 2*) | ||||
|   DATA_DIR="/data" | ||||
|   ;; | ||||
| 3*) | ||||
|   DATA_DIR="/data" | ||||
|   ;; | ||||
| *) | ||||
|   echo "ERROR: No persistent storage found." 1>&2 | ||||
|   exit 1 | ||||
|   ;; | ||||
| esac | ||||
|  | ||||
| user_authorized_keys_file="$DATA_DIR/ssh/authorized_keys" | ||||
| udm_authorized_keys_file="/root/.ssh/authorized_keys" | ||||
|  | ||||
| curl -sO https://raw.githubusercontent.com/fire1ce/UDM-Persistent-SSH-Keys/main/99-ssh-keys.sh | ||||
| mv 99-ssh-keys.sh $DATA_DIR/on_boot.d/99-ssh-keys.sh | ||||
| @@ -30,10 +29,12 @@ if [ ! -f "$user_authorized_keys_file" ]; then | ||||
|   echo "Creating $user_authorized_keys_file" | ||||
|   mkdir -p $DATA_DIR/ssh | ||||
|   mkdir -p /root/.ssh/ | ||||
|   touch "$user_authorized_keys_file $udm_authorized_keys_file" | ||||
|   chmod 0644 "$user_authorized_keys_file $udm_authorized_keys_file" | ||||
|   touch "$user_authorized_keys_file" | ||||
|   chmod 0644 "$user_authorized_keys_file" | ||||
| fi | ||||
|  | ||||
| echo "==> Add you public keys to $user_authorized_keys_file" | ||||
| echo "==> run $DATA_DIR/on_boot.d/99-ssh-keys.sh to import your keys to the UDM and test them." | ||||
| echo "==> Reboot your UDM to apply the changes after you have added your keys." | ||||
| echo "==> Done." | ||||
| exit 0 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user