Skip to content

Commit

Permalink
src/hashbang.sh: Support absent private keys
Browse files Browse the repository at this point in the history
Closes #168
  • Loading branch information
KellerFuchs committed May 8, 2023
1 parent 034ffd4 commit d94bc42
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/hashbang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ echo " yourself to systems like this one without ever sending your password ";
echo " over the internet, and thus by nature we won't even know what it is";

for keytype in id_ed25519 id_ecdsa id_rsa id_dsa; do
if [ -e ~/.ssh/${keytype}.pub ] && [ -e ~/.ssh/${keytype} ]; then
if [ -e ~/.ssh/${keytype}.pub ]; then
if ask " We found a public key in [ ~/.ssh/${keytype}.pub ]. Use this key?" Y; then
private_keyfile="${HOME}/.ssh/${keytype}"
public_key="$(cat ~/.ssh/${keytype}.pub)"
break
if [ -e ~/.ssh/${keytype} ] || ask " Are you sure? There is no corresponding private key file." N; then
private_keyfile="${HOME}/.ssh/${keytype}"
public_key="$(cat ~/.ssh/${keytype}.pub)"
break
fi
fi
fi
done
Expand Down

0 comments on commit d94bc42

Please sign in to comment.