Created
April 27, 2017 20:45
-
-
Save sjmcgrath/715caf5832d4d147274e5f53e4a8f46d to your computer and use it in GitHub Desktop.
Save your ssh-agent environment to a temp file so you can reload it in screen sessions/etc. that have the environment from a previous ssh session.
This file contains 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_AGENT_FIX_ENV_FILE="${SSH_AGENT_FIX_ENV_FILE:=$HOME/tmp/ssh-agent-env}" | |
SSH_AGENT_FIX_ENV_DIR=$( dirname ${SSH_AGENT_FIX_ENV_FILE} ) | |
[[ -d ${SSH_AGENT_FIX_ENV_DIR} ]] || { | |
mkdir -p $SSH_AGENT_FIX_ENV_DIR | |
} | |
env \ | |
| grep SSH \ | |
| sed "s/=/='/; s/$/'/" \ | |
| tee $SSH_AGENT_FIX_ENV_FILE \ | |
| sed "s/=.*//; s/^/export /" \ | |
>> $SSH_AGENT_FIX_ENV_FILE | |
echo To set the SSH agent environment correctly, run the following in your screen session. | |
echo . "$SSH_AGENT_FIX_ENV_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment