Git 配置了 alias 后,执行 ssh-add ~/.ssh/xx
的时候出现:
Could not open a connection to your authentication agent
怎么配置?
Git 配置了 alias 后,执行 ssh-add ~/.ssh/xx
的时候出现:
Could not open a connection to your authentication agent
怎么配置?
如果是Windows平台,打开C:\Program Files\Git\etc
,然后在 profile 文件中追加:
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
然后重启终端。