Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. MYCRYPT=#directory for stored SSH key encrypted with Keybase
  3. MYSERVER=#SSH server
  4.  
  5. MYKEY="$(mktemp)"
  6. chmod 600 $MYKEY
  7. printf '%s\n' "Please press the button on your authenticator. We will then write to the file." >&2
  8. head -c 4822 < $1 > $MYKEY
  9. gpg --import $MYKEY
  10. MYPRINT="$(gpg --with-fingerprint --with-colons --list-secret-key | gcut -d':' -f5 | head -n 1)"
  11.  
  12. printf '%s\n' "Your fingerprint is $MYPRINT. Creating and decrypting identity file..." >&2
  13. MYFILE="$(mktemp)"
  14. chmod 600 $MYFILE
  15. keybase pgp decrypt -i $MYCRYPT > $MYFILE
  16.  
  17. printf '\n' >&2
  18. printf '%s\n' "=== SSH CREDENTIALS ===" >&2
  19. printf '%s\n' "You may now enter your SSH credentials." >&2
  20. printf '%s\n' "Note that in some cases credentials do not need to be entered." >&2
  21. printf '%s\n' "=== SSH CREDENTIALS ===" >&2
  22. printf '\n' >&2
  23. ssh -i $MYFILE $MYSERVER $2
  24. rm $MYFILE
  25.  
  26. printf '\n' >&2
  27. printf '%s\n' "=== KEY WIPE ===" >&2
  28. printf '%s\n' "For security reasons, please wipe your key." >&2
  29. printf '%s\n' "Answer yes to the prompts." >&2
  30. printf '%s\n' "=== KEY WIPE ===" >&2
  31. printf '\n' >&2
  32. gpg --delete-secret-key --yes $MYPRINT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement