按照Github的帮助文档,将生成的SSH key添加到GitHub里了,通过下面的测试代码也返回成功了
ssh -T git@github.com
ssh key在登录服务器的时候可以不用每次输入用户名和密码,我以为git里也是提供这个功能,但是在命令行中提交私有仓库代码的时候,每次还是要输入用户名和密码,到底这key正确的使用方法是怎样的呢?
PHP中文网2017-04-21 11:19:02
Edit the .git/config file in the project directory
Found:
[remote "origin"] url =https://github.com/hit9/hit9.github.com.git fetch = +refs/heads/*:refs/remotes/origin/*
Change the url to the ssh address:
[remote "origin"] url =git@github.com:hit9/hit9.github.com.git fetch = +refs/heads/*:refs/remotes/origin/*
When the url is https, username authentication will be used. When it is an ssh address, ssh authentication will be used
伊谢尔伦2017-04-21 11:19:02
I encountered this problem before, so I just changed the remote address of the HTTPS protocol to SSH (git@github.com:name/code.git).
The SSH method and HTTPS method of the repository are different. On the surface, the URL information is different, but the actual authentication mechanism is also different. After the local key is established, there is actually no need to authenticate again when using ssh, while https requires entering a password each time.
PHP中文网2017-04-21 11:19:02
The password you need to enter should be the security policy implemented by github. The user name and password you enter are github’s username and password
阿神2017-04-21 11:19:02
You can modify it with the following command to change the HTTPS branch to the SSH branch. The effect is the same as modifying the .git/config filegit remote rm origin
git remote rm origin
git remote add origin git@github.com:twlkyao/demo.git
git push origin
git remote add origin git@github.com:twlkyao /demo.git
git push origin
🎜高洛峰2017-04-21 11:19:02
I also encountered this problem yesterday. I had to enter a password every time I submitted. Later, when I used ssh to clone, I couldn't enter the password. . .