mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
8043e6ae6a
* add support for multiple keys to be added; converts private key to dropbear for unifi scp use * change ssh id filename for dropbear default using .ssh/id_dropbear is dropbear's default id file so no need to use `ssh -i /root/id_rsa` any more.
32 lines
968 B
Bash
32 lines
968 B
Bash
#!/bin/sh
|
|
|
|
#####################################################
|
|
# ADD RSA KEYS AS BELOW - CHANGE BEFORE RUNNING #
|
|
#####################################################
|
|
# set -- "ssh-rsa first key here all keys quoted" \ #
|
|
# "ssh-rsa each line appended with slash " \ #
|
|
# "ssh-rsa last one has no backslash" #
|
|
#####################################################
|
|
set -- "ssh-rsa AAAABUNCHOFCHARACTERSANDSTUFF me on MyMachine" \
|
|
"ssh-rsa AAAADIFFERENTKEYWITHCHARSETC! user@myhost"
|
|
|
|
KEYS_FILE="/root/.ssh/authorized_keys"
|
|
|
|
counter=0
|
|
for key in "$@"
|
|
do
|
|
## Places public key in ~/.ssh/authorized_keys if not present
|
|
if ! grep -Fxq "$key" "$KEYS_FILE"; then
|
|
let counter++
|
|
echo "$key" >> "$KEYS_FILE"
|
|
fi
|
|
done
|
|
|
|
echo $counter keys added to $KEYS_FILE
|
|
|
|
echo Converting SSH private key to dropbear format
|
|
#convert ssh key to dropbear for shell interaction
|
|
dropbearconvert openssh dropbear /mnt/data/ssh/id_rsa /root/.ssh/id_dropbear
|
|
|
|
exit 0;
|