Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #!/bin/bash
  2. MYCRYPT=#directory for stored SSH key encrypted with Keybase
  3. MYSERVER=#SSH server
  4.  
  5. printf '%s\n' "Please enter your password. (change ownership of the Serial Port)" >&2
  6. sudo chmod 666 $1
  7.  
  8. printf '%s\n' "Changing stty settings..." >&2
  9. stty -F $1 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
  10.  
  11. MYKEY="$(mktemp)"
  12. chmod 600 $MYKEY
  13. printf '%s\n' "Please press the button on your authenticator. We will then write to the file." >&2
  14. head -c 4822 < $1 > $MYKEY
  15. gpg --import $MYKEY
  16. MYPRINT="$(gpg --with-fingerprint --with-colons --list-secret-key | cut -d':' -f5 | head -n 1)"
  17.  
  18. printf '%s\n' "Your fingerprint is $MYPRINT. Creating and decrypting identity file..." >&2
  19. MYFILE="$(mktemp)"
  20. chmod 600 $MYFILE
  21. keybase pgp decrypt -i $MYCRYPT > $MYFILE
  22.  
  23. printf '\n' >&2
  24. printf '%s\n' "=== SSH CREDENTIALS ===" >&2
  25. printf '%s\n' "You may now enter your SSH credentials." >&2
  26. printf '%s\n' "Note that in some cases credentials do not need to be entered." >&2
  27. printf '%s\n' "=== SSH CREDENTIALS ===" >&2
  28. printf '\n' >&2
  29. ssh -i $MYFILE $MYSERVER $2
  30. rm $MYFILE
  31.  
  32. printf '\n' >&2
  33. printf '%s\n' "=== KEY WIPE ===" >&2
  34. printf '%s\n' "For security reasons, please wipe your key." >&2
  35. printf '%s\n' "Answer yes to the prompts." >&2
  36. printf '%s\n' "=== KEY WIPE ===" >&2
  37. printf '\n' >&2
  38. gpg --delete-secret-key --yes $MYPRINT
  39.  
  40. stty sane
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement