Last active
September 22, 2022 03:39
-
-
Save kevmul/f4478b0cd8eb1c31100b9af59886b199 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
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# SSH - Windows | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Start the SSH agent and init temp $env | |
env=~/.ssh/agent.env | |
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } | |
agent_start () { | |
(umask 077; ssh-agent >| "$env") | |
. "$env" >| /dev/null; } | |
# Get your agent running and add your new key | |
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then | |
agent_start | |
ssh-add | |
ssh-add <YOUR NEW KEY> | |
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then | |
ssh-add | |
ssh-add <YOUR NEW KEY> | |
fi | |
# Delete the temp $env | |
unset env | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# SSH - Macintosh | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Get your agent running and add your new key | |
# If working with zShell, add `-z` before "$SSH_AUTH_SOCK" | |
# IE: if [ ! -z "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then | |
if [ ! -z "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then | |
ssh-add | |
ssh-add <YOUR NEW KEY> | |
elif [ -z "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then | |
ssh-add | |
ssh-add <YOUR NEW KEY> | |
fi | |
# Delete the temp $env | |
unset env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment