【发布时间】:2021-12-05 02:54:13
【问题描述】:
每当我在 Windows 上执行一些涉及我的远程存储库的操作时,例如 git pull、git remote update 或 git push(以及其他),Windows 都会不断要求我通知我的 SSH 密钥。有没有办法阻止这种情况?
【问题讨论】:
每当我在 Windows 上执行一些涉及我的远程存储库的操作时,例如 git pull、git remote update 或 git push(以及其他),Windows 都会不断要求我通知我的 SSH 密钥。有没有办法阻止这种情况?
【问题讨论】:
您可以在打开 bash 或 Git 时自动运行 ssh-agent 贝壳。复制以下行并将它们粘贴到
~/.profile或 Git Shell 中的~/.bashrc文件:
# Auto-launching ssh-agent on Git for Windows
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
但在我的情况下,我没有提到这些文件,所以我所做的是在我的 C:\Users\<username> 目录中创建一个名为 .bashrc 的文件并粘贴指示的代码。
可能是您第一次打开 git bash 或尝试执行一些涉及远程的操作时,它会要求您输入密码,但在您第一次输入后,它不会再要求您输入密码了。
【讨论】: