Skip to content

Instantly share code, notes, and snippets.

@EmperorRXF
Last active April 19, 2019 09:50
Show Gist options
  • Save EmperorRXF/c6e109cb6231f9a2c09b7ddfbdc63eec to your computer and use it in GitHub Desktop.
Save EmperorRXF/c6e109cb6231f9a2c09b7ddfbdc63eec to your computer and use it in GitHub Desktop.
Import Putty PPK files into Linux OpenSSH Agent
#!/bin/bash
DEFAULT_PPK_PATH=/mnt/UltraDisk/Dev/SSH-Keys
read -e -i $DEFAULT_PPK_PATH -p "Path to PPK Files to Import: " PPK_PATH
if [ -z "$PPK_PATH" ]
then
echo "Nothing Imported!"
else
for FILE in "$PPK_PATH"/*.ppk; do
[ -e "$FILE" ] || continue
SHORT_NAME="$(basename -s .ppk $FILE)"
puttygen "$FILE" -O private-openssh -o "$HOME/.ssh/id_rsa_$SHORT_NAME"
puttygen "$FILE" -L > "$HOME/.ssh/id_rsa_$SHORT_NAME.pub"
ssh-add "$HOME/.ssh/id_rsa_$SHORT_NAME"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment