简体   繁体   English

如何在 Windows 上删除 git bash ssh 身份验证

[英]How to remove git bash ssh authentication on windows

Whenever i go to do some operation on Windows involving my remote repository like git pull , git remote update or git push (among others) Windows keeps asking me to inform my SSH key.每当我在 Windows 上执行一些涉及远程存储库的操作时,例如git pullgit remote updategit push (以及其他),Windows 一直要求我通知我的 SSH 密钥。 Is there any way to stop this?有什么办法可以阻止这种情况吗?

Yes.是的。 As described at: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases#auto-launching-ssh-agent-on-git-for-windows如以下所述: https : //docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases#auto-launching-ssh-agent-on-git- for-windows

You can run ssh-agent automatically when opening bash or the Git shell.您可以在打开 bash 或 Git shell 时自动运行 ssh-agent。 Copy the following lines and paste them into the ~/.profile or ~/.bashrc file in Git Shell:复制以下几行并将它们粘贴到 Git Shell 中的~/.profile~/.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

But in my case I didn't have those files mentioned so what I did was create in my C:\\Users\\<username> directory a file called .bashrc and paste the code indicated.但就我而言,我没有提到这些文件,所以我所做的是在我的C:\\Users\\<username>目录中创建一个名为.bashrc的文件并粘贴指示的代码。

It could be that the first time you open your git bash or try to do some operation involving the remote it will ask you for your password, but after you enter this first time it will not ask for any more.可能是您第一次打开 git bash 或尝试执行一些涉及遥控器的操作时,它会要求您输入密码,但在您第一次输入后,它就不会再要求了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM