为了避免每次push都输入密码,按照github的要求配置了ssh key后,明明
ssh -T git@github.com 都可以返回正确的结果,但是在push的时候还是要求输入用户名跟密码。
搜索了一番之后在StackOverflow看到了这个答案
SSH Key - Still asking for password and passphrase
If you work with
HTTPsurls, it’ll always ask for your username / password.If you’re correctly using
SSHwhen cloning / setting remotes. Then make sure you have a ssh-agent to remember your password. That way, you’ll only enter your passphrase once by terminal session.If it is still too annoying, then simply set a ssh-key without passphrase.
看了下个人项目下的.git/config里的配置,果然是使用https传输
根据github的这个doc,修改成ssh传输方式后尝试。
还是不行,在push的时候依然显示git-remote-https,而不是走ssh,为什么呢?想想应该是这个repo的原因,是不是在hexo deploy的时候执行了什么优先级更高的命令。
搜索了下,要在_config.yml里的deploy相应修改才可以,并且如果在更换为ssh模式之前使用https进行过部署,则要先把.deploy_git文件夹删除掉
运行rm -rf .deploy_git即可
要多这一步的原因是,hexo d 这个命令是根据_config.yml文件里的配置来部署的。因而如果是正常的repo进行到前一步就够了,类似hexo的东西则需要在配置文件中再进行相应的修改。
修改后就正常走ssh了,push时也不再需要输入账号密码