Created
January 16, 2025 06:34
-
-
Save apsun/100496d296ca598ab551264700f499d0 to your computer and use it in GitHub Desktop.
Export gpg/ssh keys for https://mssun.github.io/passforios/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
GPG_KEY_ID='<[email protected]>' | |
DEVICE_NAME='yourhostname' | |
# mount | |
d=$(mktemp -d) | |
ifuse --documents me.mssun.passforios "$d" | |
# gpg key | |
gpg --export-secret-keys --armour "$GPG_KEY_ID" > "$d"/gpg_key | |
gpg --export --armor "$GPG_KEY_ID" > "$d"/gpg_key.pub | |
# ssh key | |
ssh-keygen -t ed25519 -C pass@"$DEVICE_NAME" -f "$d"/ssh_key -N '' | |
sudo sed -i /pass@"$DEVICE_NAME"/d /srv/git/.ssh/authorized_keys | |
sudo tee -a /srv/git/.ssh/authorized_keys < "$d"/ssh_key.pub | |
cat "$d"/ssh_key.pub | EDITOR=tee pass edit ssh/pass@"$DEVICE_NAME" | |
pass git push | |
rm "$d"/ssh_key.pub | |
# unmount | |
fusermount -u "$d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment