git 当我尝试从本地推送到远程 gitlab 存储库时权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29218852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permission denied when I try to push from local to remote gitlab repository
提问by a.toraby
I have created a repository in gitlab web ui and tried to push my local repository. I added remote repo using the following command:
我在 gitlab web ui 中创建了一个存储库并尝试推送我的本地存储库。我使用以下命令添加了远程仓库:
$ git remote add origin [email protected]:project.git
Then I tried to push but it errors. I don't use ssl. I want to use plain text connection.
然后我尝试推送但它出错了。我不使用ssl。我想使用纯文本连接。
$ git push origin master
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
回答by VonC
Then I created the test user from web ui. and created the project with the test user.
然后我从 web ui 创建了测试用户。并使用 test 用户创建了项目。
You would never use that user for contacting a server in ssh: all the authorized keys are grouped under oneaccount, which for gitlab should be git
: ~git/.ssh/authorized_keys
您永远不会使用该用户在 ssh 中联系服务器:所有授权密钥都分组在一个帐户下,对于 gitlab 应该是git
:~git/.ssh/authorized_keys
See config/gitlab.yml
.
So try:
所以尝试:
git remote set-url origin [email protected]:project.git
回答by Rick Stevens
Newer versions of ssh also disallow DSA key use by default. Make sure you're using RSA keys or make sure your ~/.ssh/config or /etc/ssh/ssh_config files permit DSA keys. You can do this by adding something like this to the appropriate file:
默认情况下,较新版本的 ssh 也不允许使用 DSA 密钥。确保您使用的是 RSA 密钥或确保您的 ~/.ssh/config 或 /etc/ssh/ssh_config 文件允许 DSA 密钥。您可以通过在适当的文件中添加类似的内容来做到这一点:
Host your.git.server
KexAlgorithms +diffie-hellman-group1-sha1
HostkeyAlgorithms ssh-dss,ssh-rsa
This one bit me.
这一点我。
回答by Sibeesh Venu
One of my colleagues was facing the same issue. For him, it was the issue with setting the SSH. It seems like the credential used was incorrect. And just cleaning that resolved that issue.
我的一位同事也面临同样的问题。对他来说,这是设置 SSH 的问题。使用的凭据似乎不正确。只需清洁即可解决该问题。
$ git config --system --unset credential.helper
$ git config --global --unset credential.helper
Thanks to Patthoyts for this answer.
感谢 Patthoyts 的回答。