From b3345f396c579d1f1915c9d3b8142be19ffebce7 Mon Sep 17 00:00:00 2001 From: fire1ce Date: Sat, 12 Feb 2022 23:11:35 +0200 Subject: [PATCH] initial release --- .gitignore | 26 ++++++++++++++++++++++++++ 99-ssh-keys.sh | 18 ++++++++++++++++++ README.md | 7 ++++++- install.sh | 15 +++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100755 99-ssh-keys.sh create mode 100644 install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7bcaed --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/99-ssh-keys.sh b/99-ssh-keys.sh new file mode 100755 index 0000000..e503d02 --- /dev/null +++ b/99-ssh-keys.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +user_authorized_keys_file="/mnt/data/ssh/authorized_keys" +udm_authorized_keys_file="/root/.ssh/authorized_keys" + +# if /mnt/data/ssh/authorized_keys is missing print error message +if [ ! -f "$user_authorized_keys_file" ]; then + echo "ERROR: $user_authorized_keys_file is missing" + exit 1 +fi + +# Reads the user file line by line and adds the key to the authorized_keys file +file=$user_authorized_keys_file +while IFS= read -r line || [ -n "$line" ]; do + echo $line >>$udm_authorized_keys_file +done <"$file" + +exit 0 diff --git a/README.md b/README.md index f290aa1..d884f78 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# UDMP-Persistence-SSH-Keys +# UDMP Persistence SSH Keys + +## Persistence on Reboot + +The setup script must be run every time the system is rebooted since the __/root/.ssh/authorized_keys__ overwrites every boot. +This can be accomplished with a boot script. Flow its guide [UDM / UDMPro Boot Script]([UDM / UDMPro Boot Script](https://github.com/boostchicken-dev/udm-utilities/tree/master/on-boot-script)){target=_blank} \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..56114bf --- /dev/null +++ b/install.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +user_authorized_keys_file="/mnt/data/ssh/authorized_keys" + +curl -O https://raw.githubusercontent.com/fire1ce/ +mv 99-ssh-keys.sh /mnt/data/on_boot.d/99-ssh-keys.sh +chmod +x /mnt/data/on_boot.d/99-ssh-keys.sh + +if [ ! -f "$user_authorized_keys_file" ]; then + touch $user_authorized_keys_file +fi + +chmod 0644 $user_authorized_keys_file + +exit 0