|
@ -1,13 +1,15 @@ |
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
FINGERPRINT="2048 SHA256:pBz+GiWLvh9uccTB50HTQOCXhD9FZPFin/tfGKAZApQ" |
|
|
|
|
|
KEYURL="https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ssh/altinea-rsa.pub" |
|
|
|
|
|
|
|
|
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 |
|
|
if [ -x "$(which curl)" ] ; then |
|
|
COMMAND="curl $KEYURL" |
|
|
|
|
|
|
|
|
COMMAND="curl $" |
|
|
echo "Found curl, using it" |
|
|
echo "Found curl, using it" |
|
|
elif [ -x "$(which wget)" ]; then |
|
|
elif [ -x "$(which wget)" ]; then |
|
|
COMMAND="wget -q -O - $KEYURL" |
|
|
|
|
|
|
|
|
COMMAND="wget -q -O - " |
|
|
echo "Found wget, fallback to that" |
|
|
echo "Found wget, fallback to that" |
|
|
else |
|
|
else |
|
|
echo "Could not find curl or wget, please install one." >&2 |
|
|
echo "Could not find curl or wget, please install one." >&2 |
|
@ -26,13 +28,22 @@ then |
|
|
exit 1; |
|
|
exit 1; |
|
|
else |
|
|
else |
|
|
touch ~/.ssh/authorized_keys |
|
|
touch ~/.ssh/authorized_keys |
|
|
if [ $(grep -c "$FINGERPRINT" <(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null)) -eq 1 ] |
|
|
|
|
|
|
|
|
if [ $(grep -c "$RSA_FINGERPRINT" <(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null)) -eq 1 ] |
|
|
then |
|
|
then |
|
|
echo "Altinea CA fingerprint found in authorized_keys file, not adding" |
|
|
|
|
|
|
|
|
echo "Altinea RSA CA fingerprint found in authorized_keys file, not adding" |
|
|
exit 2; |
|
|
exit 2; |
|
|
else |
|
|
else |
|
|
$COMMAND >> ~/.ssh/authorized_keys |
|
|
|
|
|
echo "Altinea CA SSH key deployed on this account" |
|
|
|
|
|
|
|
|
$COMMAND $RSA_KEYURL >> ~/.ssh/authorized_keys |
|
|
|
|
|
echo "Altinea RSA CA key deployed on account" `whoami` |
|
|
|
|
|
exit 0; |
|
|
|
|
|
fi |
|
|
|
|
|
if [ $(grep -c "$ED25519_FINGERPRINT" <(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null)) -eq 1 ] |
|
|
|
|
|
then |
|
|
|
|
|
echo "Altinea ED25519 CA fingerprint found in authorized_keys file, not adding" |
|
|
|
|
|
exit 2; |
|
|
|
|
|
else |
|
|
|
|
|
$COMMAND $ED25519_KEYURL >> ~/.ssh/authorized_keys |
|
|
|
|
|
echo "Altinea ED25519 CA key deployed on account" `whoami` |
|
|
exit 0; |
|
|
exit 0; |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|