Last active
April 14, 2025 19:22
-
-
Save apjyotirmay/9115d4ea19b35d5b18729cedbab313cf to your computer and use it in GitHub Desktop.
Export public keys from your ssh agent keyring
This file contains hidden or 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
#!/usr/bin/env bash | |
# This script exports your public keys from ssh keyring and saves it in ~/.ssh/pub | |
# with the name. This makes it easy to avoid brute forcing all key in the agent | |
[[ -e $HOME/.ssh/pub ]] || mkdir $HOME/.ssh/pub | |
while read -r line | |
do | |
FILENAME=$(echo $line | awk '{print $3}') | |
echo $line > "${HOME}/.ssh/pub/${FILENAME}.pub" | |
chmod 600 "${HOME}/.ssh/pub/${FILENAME}.pub" | |
done < <(ssh-add -L) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment