Created
May 10, 2017 23:01
-
-
Save frntn/66fdeb16b5c62b8b53640a2f4a700fae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd "$(dirname "$0")" | |
GIT_KEYS="gitkey_*" # my git keys are always loaded but agent forwarding is limited specific Hosts | |
SSH_KEYS="" # my ssh keys are never loaded | |
SSH_AGENT_PID=1 # `kill -0 1` will always fail for non-root | |
SSH_AGENT_ENV=".agent_env" | |
[ -f "${SSH_AGENT_ENV}" ] && source "${SSH_AGENT_ENV}" > /dev/null # load latest known agent pid | |
kill -0 $SSH_AGENT_PID 2>/dev/null && return # and stop here if still running (do not 'exit' because file may be source'd) | |
echo "Loading SSH Agent..." | |
chmod -f 600 "${SSH_AGENT_ENV}" | |
/usr/bin/ssh-agent > "${SSH_AGENT_ENV}" # overwrite latest (not running anymore) | |
source "${SSH_AGENT_ENV}" > /dev/null | |
for key in $GIT_KEYS; do /usr/bin/ssh-add "$key"; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ...stuff before... | |
for i in ~/.bash_aliases ~/.ssh/.agent_loader | |
do | |
[ -f "$i" ] && source "$i" | |
done | |
# ...stuff after... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ssh-keygen -f ~/.ssh/gitkey_git.example.com -P randompass -t ed25519 -C "[email protected] for git.example.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment