You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.5 KiB

#!/bin/sh
RSA_FINGERPRINT="2048 SHA256:pBz+GiWLvh9uccTB50HTQOCXhD9FZPFin/tfGKAZApQ"
RSA_KEYURL="https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ssh/altinea-rsa.pub"
ED25519_FINGERPRINT="SHA256:TagxgsBxZhHFWiThYwe/hZSYjLBOHWBY2Ss0QsipmTw noc@altinea.fr"
ED25519_KEYURL="https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ssh/altinea-ed25519.pub"
if [ -x "$(which curl)" ] ; then
COMMAND="curl -s "
echo "Found curl, using it"
elif [ -x "$(which wget)" ]; then
COMMAND="wget -q -O - "
echo "Found wget, fallback to that"
else
echo "Could not find curl or wget, please install one." >&2
exit 3;
fi
if [ ! -d ~/.ssh ]; then
mkdir ~/.ssh
chmod 700 ~/.ssh
fi
if [ -w ~/.ssh/authorized_keys2 ]
then
echo "It seems you're still relying on authorized_keys2, this is (almost) deprecated."
exit 1;
else
touch ~/.ssh/authorized_keys
if [ $(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null |grep -c "$RSA_FINGERPRINT") -ne 0 ]
then
echo "Altinea RSA CA fingerprint found in authorized_keys file, not adding"
else
$COMMAND $RSA_KEYURL >> ~/.ssh/authorized_keys
echo "Altinea RSA CA key deployed on account" `whoami`
fi
if [ $(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null |grep -c "$ED25519_FINGERPRINT") -ne 0 ]
then
echo "Altinea ED25519 CA fingerprint found in authorized_keys file, not adding"
else
$COMMAND $ED25519_KEYURL >> ~/.ssh/authorized_keys
echo "Altinea ED25519 CA key deployed on account" `whoami`
fi
fi
exit 0;