2022-02-12 23:11:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-12-18 11:49:06 +01:00
|
|
|
# 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
|
|
|
|
|
|
|
|
user_authorized_keys_file="$DATA_DIR/ssh/authorized_keys"
|
2022-12-18 11:52:09 +01:00
|
|
|
udm_authorized_keys_file="/root/.ssh/authorized_keys"
|
2022-02-12 23:11:35 +02:00
|
|
|
|
2022-07-23 19:17:26 +03:00
|
|
|
curl -sO https://raw.githubusercontent.com/fire1ce/UDM-Persistent-SSH-Keys/main/99-ssh-keys.sh
|
2022-12-18 11:49:06 +01:00
|
|
|
mv 99-ssh-keys.sh $DATA_DIR/on_boot.d/99-ssh-keys.sh
|
|
|
|
chmod +x $DATA_DIR/on_boot.d/99-ssh-keys.sh
|
2022-02-12 23:14:24 +02:00
|
|
|
echo "99-ssh-keys.sh installed"
|
2022-02-12 23:11:35 +02:00
|
|
|
|
|
|
|
if [ ! -f "$user_authorized_keys_file" ]; then
|
2022-02-12 23:14:24 +02:00
|
|
|
echo "Creating $user_authorized_keys_file"
|
2022-12-18 11:49:06 +01:00
|
|
|
mkdir -p $DATA_DIR/ssh
|
2022-12-18 11:52:09 +01:00
|
|
|
mkdir -p /root/.ssh/
|
|
|
|
touch "$user_authorized_keys_file $udm_authorized_keys_file"
|
|
|
|
chmod 0644 "$user_authorized_keys_file $udm_authorized_keys_file"
|
2022-02-12 23:11:35 +02:00
|
|
|
fi
|
|
|
|
|
2022-07-23 19:17:26 +03:00
|
|
|
echo "==> Add you public keys to $user_authorized_keys_file"
|
|
|
|
echo "==> Done."
|
2022-02-12 23:11:35 +02:00
|
|
|
exit 0
|