added code comments

This commit is contained in:
Bryan Black 2018-07-19 15:05:24 -07:00 committed by GitHub
parent 9e78c21127
commit 023fc2cb6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,16 @@
#!/bin/bash #!/bin/bash
function gpg-agent-forward() { function gpg-agent-forward() {
# BEGIN variables
# Input variables
ruser=$1 ruser=$1
hostshortcut=$(cat /dev/urandom | env LC_CTYPE=C tr -dc "a-z0-9" | fold -w 3 | head -n 1)
hostname=$2 hostname=$2
# Generates random 3 character host shortcut. LC_CTYPE is needed for OS X and FreeBSD.
# https://gist.github.com/earthgecko/3089509
hostshortcut=$(cat /dev/urandom | env LC_CTYPE=C tr -dc "a-z0-9" | fold -w 3 | head -n 1)
# END VARIABLES
# BEGIN script
touch ~/.ssh/config touch ~/.ssh/config
echo "CREATING GPG-AGENT FORWARDING CONFIG" echo "CREATING GPG-AGENT FORWARDING CONFIG"
echo "YOUR HOST SHORTCUT IS \"$hostshortcut\"" echo "YOUR HOST SHORTCUT IS \"$hostshortcut\""
@ -15,7 +22,11 @@ echo " RemoteForward /home/$ruser/.gnupg/S.gpg-agent.ssh $HOME/.gnupg/S.gpg-age
echo " ServerAliveInterval 10" >> ~/.ssh/config echo " ServerAliveInterval 10" >> ~/.ssh/config
echo "Use this shortcut to forward your Yubikey to $host:" echo "Use this shortcut to forward your Yubikey to $host:"
echo " ssh $hostshortcut" echo " ssh $hostshortcut"
echo "Inspect or edit the config:"
echo " vi ~/.ssh/config"
echo "DONE"
return 0 return 0
# END script
} }
gpg-agent-forward $1 $2 gpg-agent-forward $1 $2