Created
June 17, 2021 10:43
-
-
Save szmeku/3733474ab56a9eedb3f73930c975b635 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_ENV="$HOME/.ssh/environment" | |
| function run_ssh_env { | |
| . "${SSH_ENV}" > /dev/null | |
| } | |
| function start_ssh_agent { | |
| echo "Initializing new SSH agent..." | |
| ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
| echo "succeeded" | |
| chmod 600 "${SSH_ENV}" | |
| run_ssh_env; | |
| ssh-add ~/.ssh/id_rsa; | |
| } | |
| if [ -f "${SSH_ENV}" ]; then | |
| run_ssh_env; | |
| ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { | |
| start_ssh_agent; | |
| } | |
| else | |
| start_ssh_agent; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment