Check for ssh public key

This commit is contained in:
Bob Mottram 2015-10-31 20:26:00 +00:00
parent 74673601e9
commit 1713d292d1
1 changed files with 13 additions and 11 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
MY_USERNAME=$1
SSH_PUBLIC_KEY=$2
SSH_PUBLIC_KEY="$2"
GPG_KEYSERVER='hkp://keys.gnupg.net'
SSH_PORT=2222
COMPLETION_FILE=$HOME/freedombone-completed.txt
@ -30,19 +30,21 @@ if [ ! -d /home/$MY_USERNAME ]; then
exit 4
fi
if [ $2 ]; then
if [ -f $SSH_PUBLIC_KEY ]; then
mkdir /home/$MY_USERNAME/.ssh
cp $SSH_PUBLIC_KEY /home/$MY_USERNAME/.ssh/authorized_keys
echo 'ssh public key installed'
else
if [[ $SSH_PUBLIC_KEY == "ssh-"* ]]; then
if [ "$SSH_PUBLIC_KEY" ]; then
if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
if [ -f $SSH_PUBLIC_KEY ]; then
mkdir /home/$MY_USERNAME/.ssh
echo $SSH_PUBLIC_KEY > /home/$MY_USERNAME/.ssh/authorized_keys
cp $SSH_PUBLIC_KEY /home/$MY_USERNAME/.ssh/authorized_keys
echo 'ssh public key installed'
else
echo 'The second parameter does not look like an ssh key'
exit 5
if [[ $SSH_PUBLIC_KEY == "ssh-"* ]]; then
mkdir /home/$MY_USERNAME/.ssh
echo $SSH_PUBLIC_KEY > /home/$MY_USERNAME/.ssh/authorized_keys
echo 'ssh public key installed'
else
echo 'The second parameter does not look like an ssh key'
exit 5
fi
fi
fi
fi