Original link: https://hsiaofeng.com/archives/193.html
It is found that every time I connect to GitHub, an SSH error occurs because the ssh-agent is not running.
Append the following configuration to ~/.profile
or ~/.bashrc
file.
env=~/.ssh/agent.env agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } agent_start () { (umask 077; ssh-agent >| "$env") . "$env" >| /dev/null ; } agent_load_env # agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then agent_start ssh-add elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then ssh-add fi unset env
References
https://zhuanlan.zhihu.com/p/126117538
This article is reproduced from: https://hsiaofeng.com/archives/193.html
This site is for inclusion only, and the copyright belongs to the original author.