git 为什么上限部署给予权限被拒绝(公钥)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7968656/
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
Why is a cap deploy giving Permission denied (publickey)?
提问by GiH
Ok, I'm confused about something... I am able to commit to my github repository just fine, but when I try to do a cap deploy
from my local folder to my staging server I get Permission denied (publickey).
好吧,我对某些事情感到困惑......我能够很好地提交到我的 github 存储库,但是当我尝试cap deploy
从本地文件夹到我的登台服务器时,我得到了Permission denied (publickey).
If I run ssh [email protected]
I actually get an error PTY allocation request failed on channel 0
如果我运行,ssh [email protected]
我实际上会收到错误PTY allocation request failed on channel 0
So something here is wrong.
所以这里有些不对劲。
If I run ssh -vT [email protected]
I get:
如果我跑ssh -vT [email protected]
我得到:
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/myuser/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug1: identity file /Users/myuser/.ssh/id_rsa type 1
debug1: identity file /Users/myuser/.ssh/id_rsa-cert type -1
debug1: identity file /Users/myuser/.ssh/id_dsa type -1
debug1: identity file /Users/myuser/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2
debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/myuser/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/myuser/.ssh/github_rsa
debug1: Remote: Forced command: gerve technomad
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Remote: Forced command: gerve technomad
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([207.97.227.239]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
Hi technomad! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2384, received 2888 bytes, in 0.1 seconds
Bytes per second: sent 42630.8, received 51643.3
debug1: Exit status 1
My keys are in the ~/.ssh folder, so whats the issue, and why am i able to commit to the repository if there is a key issue??
我的密钥在 ~/.ssh 文件夹中,所以有什么问题,如果有密钥问题,为什么我能够提交到存储库?
UPDATE:I did notice something when I went into my .ssh folder. There is a new keypair that was created when I installed Github for Mac... why couldn't it just use my existing keypair i don't know.
更新:当我进入我的 .ssh 文件夹时,我确实注意到了一些事情。当我为 Mac 安装 Github 时创建了一个新的密钥对......为什么它不能只使用我不知道的现有密钥对。
采纳答案by Dave Bettin
I would make sure your staging server has ssh access to github. Run the same command "ssh -vT [email protected]" via a terminal on your staging server; this will help determine if it is ssh problem on the remote machine.
我会确保您的登台服务器可以通过 ssh 访问 github。通过临时服务器上的终端运行相同的命令“ssh -vT [email protected]”;这将有助于确定它是否是远程机器上的 ssh 问题。
回答by olore
I had to do the following:
我必须执行以下操作:
$ ssh-add -D #remove existing identities
$ ssh-agent #copy the lines & run them
$ ssh-add #uses the output from above
回答by Catfish
I get this error sometimes and I just type $ ssh-add -k
to add my identity and then it works. Not sure exactly why this works or why the error message doesn't suggest it, but it always comes in to the rescue!
我有时会收到此错误,我只需键入$ ssh-add -k
以添加我的身份,然后它就可以工作了。不确定为什么会这样,或者为什么错误消息不建议这样做,但它总是能派上用场!
回答by Jiang Xin
I met with the same problem after installing GitHub for Mac OS X. The application created a new ssh private key in ~/.ssh/github_rsa and added it to the ssh authentication agent.
我在为 Mac OS X 安装 GitHub 后遇到了同样的问题。该应用程序在 ~/.ssh/github_rsa 中创建了一个新的 ssh 私钥并将其添加到 ssh 身份验证代理。
Check which key the ssh auth agent has cached:
检查 ssh 身份验证代理缓存了哪个密钥:
$ ssh-add -l
2048 63:0c:a6:51:63:c1:35:76:5d:02:77:97:39:48:0e:4a /Users/jiangxin/.ssh/github_rsa (RSA)
Whenever you connect to github.com or another ssh services, this key is used first.
每当您连接到 github.com 或其他 ssh 服务时,首先使用此密钥。
Clear the cached keys from ssh-agent using this command:
使用以下命令从 ssh-agent 清除缓存的密钥:
$ ssh-add -D
Now the ssh client should work normally, using the key defined in ~/.ssh/config or ~/.ssh/id_rsa.
现在 ssh 客户端应该可以正常工作,使用 ~/.ssh/config 或 ~/.ssh/id_rsa 中定义的密钥。
回答by Sankalp Singha
The error is because, ssh-add does not know how to talk with the authentication agent. The problem can be solved by setting SSH_AUTH_SOCK environment variable.
错误是因为 ssh-add 不知道如何与身份验证代理交谈。该问题可以通过设置 SSH_AUTH_SOCK 环境变量来解决。
If you run ssh-agent you should get some output like this:
如果你运行 ssh-agent 你应该得到一些这样的输出:
SSH_AUTH_SOCK=/tmp/ssh-agVZL13989/agent.13989; export SSH_AUTH_SOCK;
SSH_AGENT_PID=13990; export SSH_AGENT_PID;
echo Agent pid 13990;SSH_AUTH_SOCK=/tmp/ssh-agVZL13989/agent.13989; export SSH_AUTH_SOCK;
SSH_AGENT_PID=13990; export SSH_AGENT_PID;
echo Agent pid 13990;
Execute this :
执行这个:
eval $(ssh-agent)
And then :
进而 :
ssh-add -D
回答by Rajat Bansal
If you are using MAC. Maybe your ssh key is not added to authentication agent. Following command will do that
如果您使用的是 MAC。也许您的 ssh 密钥未添加到身份验证代理。以下命令将执行此操作
ssh-add path_to_private_key
for example
例如
ssh-add ~/.ssh/id_rsa