Switching Git to use SSH

心已入冬 提交于 2021-02-11 08:13:53

问题


I have an SSH key set up and added to Git servers. Even then, while using Git from my command line, it still uses username and password for authentication. Is there are any command to change my authentication mechanism.


回答1:


I believe you're looking for credential helpers. Check out the git documentation here: https://www.kernel.org/pub/software/scm/git/docs/v1.7.9/gitcredentials.html

My guess is that git config --global credential.helper cache will do the trick.

If you're on a mac and installed git using homebrew you can use this: git config --global credential.helper osxkeychain.

There's another stack overflow question with answers that go more in depth about git credentials here: Is there a way to skip password typing when using https:// on GitHub?.

Hope this helps!




回答2:


Did you set your remote branch URL using git protocol?

You can set by

git remote set-url origin [SSH protocol URL]

SSH protocol URL looks like git@github.com:torvalds/linux.git



来源:https://stackoverflow.com/questions/42081903/switching-git-to-use-ssh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!