Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- MYCRYPT=#directory for stored SSH key encrypted with Keybase
- MYSERVER=#SSH server
- printf '%s\n' "Please enter your password. (change ownership of the Serial Port)" >&2
- sudo chmod 666 $1
- printf '%s\n' "Changing stty settings..." >&2
- stty -F $1 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
- MYKEY="$(mktemp)"
- chmod 600 $MYKEY
- printf '%s\n' "Please press the button on your authenticator. We will then write to the file." >&2
- head -c 4822 < $1 > $MYKEY
- gpg --import $MYKEY
- MYPRINT="$(gpg --with-fingerprint --with-colons --list-secret-key | cut -d':' -f5 | head -n 1)"
- printf '%s\n' "Your fingerprint is $MYPRINT. Creating and decrypting identity file..." >&2
- MYFILE="$(mktemp)"
- chmod 600 $MYFILE
- keybase pgp decrypt -i $MYCRYPT > $MYFILE
- printf '\n' >&2
- printf '%s\n' "=== SSH CREDENTIALS ===" >&2
- printf '%s\n' "You may now enter your SSH credentials." >&2
- printf '%s\n' "Note that in some cases credentials do not need to be entered." >&2
- printf '%s\n' "=== SSH CREDENTIALS ===" >&2
- printf '\n' >&2
- ssh -i $MYFILE $MYSERVER $2
- rm $MYFILE
- printf '\n' >&2
- printf '%s\n' "=== KEY WIPE ===" >&2
- printf '%s\n' "For security reasons, please wipe your key." >&2
- printf '%s\n' "Answer yes to the prompts." >&2
- printf '%s\n' "=== KEY WIPE ===" >&2
- printf '\n' >&2
- gpg --delete-secret-key --yes $MYPRINT
- stty sane
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement