git clone 通过 ssh 返回权限被拒绝(公钥,密码)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10278885/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:49:20  来源:igfitidea点击:

git clone through ssh returns Permission denied (publickey,password)

ruby-on-railsgitsshdeploymentvlad-deployer

提问by gayavat

I have production_server and git_repo_server, git_repo_server .ssh/authorized keys have production user id_rsa.pub. When I ssh to production_server and make git clone - it works fine, don't ask any password. When I try to clone git repo to production_server on my local mashine using ssh I see:

我有 production_server 和 git_repo_server,git_repo_server .ssh/授权密钥有生产用户 id_rsa.pub。当我通过 ssh 连接到 production_server 并进行 git clone 时 - 它工作正常,不要询问任何密码。当我尝试使用 ssh 将 git repo 克隆到本地 mashine 上的 production_server 时,我看到:

Permission denied, please try again.
Permission denied (publickey,password).

It looks like ssh should be configured to send commands to remote server. But I don't know how to do it. Thanks for any help!

看起来应该将 ssh 配置为向远程服务器发送命令。但我不知道该怎么做。谢谢你的帮助!

回答by gayavat

Problem was fixed. I added

问题已解决。我加了

Host * 
    ForwardAgent yes

to /etc/ssh/ssh_config

到 /etc/ssh/ssh_config

See ssh-agent tutorial

参见ssh-agent 教程

回答by Bash

I had this issue the probelm was that the user/machine from which I'm accessing Gitosis was not registered as a user in the Gitosis project, and thus access was denied.

我遇到了这个问题,问题是我访问 Gitosis 的用户/机器没有在 Gitosis 项目中注册为用户,因此访问被拒绝。

  1. If you don't have one, generate SSH key in your machine "~/.ssh$ ssh-keygen -t rsa".

  2. Use scp command to copy your public key (id_ras.pub) to gitosis_server, to gitosis_admin/keydir.

  3. Make sure you rename id_rsa.pub to [email protected], USER = the client user, SYSTEM= the client system name.

  4. Follow instructions here to add the user (USER@SYSTEM) to the project [https://help.ubuntu.com/community/Git#Adding_users]

  1. 如果您没有,请在您的机器中生成 SSH 密钥“~/.ssh$ ssh-keygen -t rsa”。

  2. 使用 scp 命令将您的公钥 (id_ras.pub) 复制到 gitosis_server,到 gitosis_admin/keydir。

  3. 确保将 id_rsa.pub 重命名为 [email protected],USER = 客户端用户,SYSTEM = 客户端系统名称。

  4. 按照此处的说明将用户 (USER@SYSTEM) 添加到项目 [https://help.ubuntu.com/community/Git#Adding_users]