%HOME% 不正确.我将变量 %HOME% 配置为在本地指向 %USERPROFILE% 并且它工作了Mysygit 确实设置了 HOME,但如果您在 git-cmd session,那么你有责任正确设置HOME.Made all necessary steps to use the GitLab, these settings are:Created a rsa as described in this linkCopied the code generated in {my key}.pub and added this code in GitLabIn my existent repository added to url with command git remote add gitlab [email protected]:ridermansb/breezenhibernateproblem.gitI tried to make the push git push -u gitlab masterMy .ssh/configHost gitlab.com HostName gitlab.com IdentityFile C:UsersRiderman.sshgitlab_rsa IdentitiesOnly yesError below:Warning: Permanently added 'gitlab.com,54.243.197.170' (RSA) to the list of known hosts.Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.I made a video showing all the steps: http://www.screenr.com/euVHWhat am I doing wrong? 解决方案 After seeing your screencast, I see that you don't have a %HOME%.sshconfig file.This is important because:by default, ssh will look for the public/private key in %HOME%.sshid_rsa(.pub)With an scp-like syntax ([email protected]:yourRepo, with the ':' as separator), ssh could look in a .ssh/config file for the location of the actual public/private key, using gitlab.com as an entry in said config file.Add %HOME%.sshconfig with:Host gitlab.com HostName gitlab.com IdentityFile C:patho.sshgitlab_rsa IdentitiesOnly yesand your git push -u gitlab master will work.It turned out it was also about setting HOME correctly:%HOME% was not correct.I configured the variable %HOME% to point to %USERPROFILE% locally and it workedMysygit does set HOME, but if you are using git outside of a git-cmd session, then it is your responsibility to set HOME correctly. 这篇关于推送到现有项目的 SSH 错误权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 03:45
查看更多