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.

39 lines
997 B

  1. #!/bin/bash
  2. FINGERPRINT="2048 SHA256:pBz+GiWLvh9uccTB50HTQOCXhD9FZPFin/tfGKAZApQ"
  3. KEYURL="https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ssh/altinea.key"
  4. if [ -x "$(which curl)" ] ; then
  5. COMMAND="curl $KEYURL"
  6. echo "Found curl, using it"
  7. elif [ -x "$(which wget)" ]; then
  8. COMMAND="wget -q -O - $KEYURL"
  9. echo "Found wget, fallback to that"
  10. else
  11. echo "Could not find curl or wget, please install one." >&2
  12. exit 3;
  13. fi
  14. if [[ ! -d ~/.ssh ]];
  15. then
  16. mkdir ~/.ssh
  17. chmod 700 ~/.ssh
  18. fi
  19. if [[ -w ~/.ssh/authorized_keys2 ]]
  20. then
  21. echo "It seems you're still relying on authorized_keys2, this is (almost) deprecated."
  22. exit 1;
  23. else
  24. touch ~/.ssh/authorized_keys
  25. if [ $(grep -c "$FINGERPRINT" <(ssh-keygen -E sha256 -lf ~/.ssh/authorized_keys 2>/dev/null)) -eq 1 ]
  26. then
  27. echo "Altinea CA fingerprint found in authorized_keys file, not adding"
  28. exit 2;
  29. else
  30. $COMMAND >> ~/.ssh/authorized_keys
  31. echo "Altinea CA SSH key deployed on this account"
  32. exit 0;
  33. fi
  34. fi
  35. exit 99;