arch-install/scripts/setup_ssh_key.sh
Ariejan de Vroom 05dc61cbd8
Some checks failed
Lint / Lint (3.10) (push) Failing after 15s
Lint / Lint (3.11) (push) Failing after 18s
Update ssh key script; deps
2024-06-07 13:44:37 +02:00

33 lines
850 B
Bash
Executable File

#!/usr/bin/env -S bash -i
if [ -f "${HOME}/.ssh/id_ed25519" ]; then
echo "SSH private key already exists. Exiting."
exit 1
fi
HOSTNAME=`hostname`
GITHUB_TOKEN=`rbw get "Github CLI Token"`
GITEA_TOKEN=`rbw get "Gitea CLI Token"`
ssh-keygen -t ed25519 -f "${HOME}/.ssh/id_ed25519" -q -P "" -C "$USER@$HOSTNAME"
gh ssh-key add "${HOME}/.ssh/id_ed25519.pub" --title "$USER@$HOSTNAME"
curl -X 'POST' \
'https://git.devroom.io/api/v1/user/keys' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: ${GITEA_TOKEN}' \
-d '{
"key": "",
"read_only": false,
"title": "$USER@$HOSTNAME"
}'
ssh-keyscan -H git.devroom.io >> "${HOME}/.ssh/known_hosts"
ssh-keyscan -H github.com >> "${HOME}/.ssh/known_hosts"
echo "--- Your public key, sir:"
echo "---"
cat "${HOME}/.ssh/id_ed25519.pub"
echo "---"