Created
May 29, 2012 22:09
-
-
Save dalbertom/2831091 to your computer and use it in GitHub Desktop.
save ssh passphrase for 8 hours.
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
| @echo off | |
| set /a TTL=8*60*60 | |
| ssh-add -l | |
| if ERRORLEVEL 2 for /f "delims=;" %%a in ('ssh-agent -t %TTL%') do set %%a 2> nul | |
| set TTL= | |
| ssh-add | |
| if ERRORLEVEL 1 ssh-add -d |
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
| # save as $HOME/.bashrc | |
| TTL=$((8 * 60 * 60)) | |
| SSH_ENV=$HOME/.ssh/environment | |
| function start_agent { | |
| ssh-agent -t $TTL > $SSH_ENV | |
| source $SSH_ENV | |
| } | |
| if [ -f $SSH_ENV ]; then | |
| source $SSH_ENV | |
| else | |
| start_agent | |
| ssh-add | |
| fi | |
| ssh-add -l | |
| case $? in | |
| 2 ) | |
| start_agent | |
| ssh-add | |
| ;; | |
| 1 ) | |
| ssh-add | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment