为什么限制部署会给出Permission denied(publickey)?

GiH*_*GiH 40 git ssh capistrano ssh-keys public-key

好吧,我对某些事感到困惑......我能够提交到我的github存储库就好了,但当我尝试cap deploy从我的本地文件夹到我的登台服务器时,我得到了Permission denied (publickey).

如果我跑,ssh git@github.com我实际上得到一个错误PTY allocation request failed on channel 0

所以这里有些错误.

如果我跑,ssh -vT git@github.com我得到:

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 no-more-sessions@openssh.com
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 eow@openssh.com 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
Run Code Online (Sandbox Code Playgroud)

我的密钥在〜/ .ssh文件夹中,所以问题是什么,为什么我能够提交到存储库,如果有一个关键问题?

更新: 当我进入我的.ssh文件夹时,我注意到了一些事情.我安装了Github for Mac时创建了一个新的密钥对...为什么它不能只使用我不知道的现有密钥对.

olo*_*ore 116

我必须做以下事情:

   $ ssh-add -D   #remove existing identities
   $ ssh-agent    #copy the lines & run them
   $ ssh-add      #uses the output from above
Run Code Online (Sandbox Code Playgroud)

  • 但是这背后的原因是什么,以及这个命令为解决这个问题做了什么? (14认同)
  • 上述命令将RSA/DSA身份添加到身份验证代理,身份验证代理在部署时检查权限.出于某种原因,如果在运行deploy命令之前未添加标识,则会收到权限被拒绝错误.对我来说,每当我重新启动计算机时,我都需要输入上述命令才能使其正常工作.我想我的ssh公钥在每次重启后都没有自动添加.所以,在上面的命令之后我使用`ssh-add -K`将输出添加到Keychain.之后我的问题永久解决了. (7认同)
  • 这是问题的准确答案.无需在舞台机器上添加ssh密钥.只需运行命令并完成...谢谢@olore (2认同)

Cat*_*ish 32

我有时会收到此错误,我只是键入$ ssh-add -k以添加我的身份,然后它就可以了.不确定为什么这个工作或为什么错误信息不建议它,但它总是来救援!


小智 19

我会确保您的登台服务器具有对github的ssh访问权限.通过登台服务器上的终端运行相同的命令"ssh -vT git@github.com"; 这将有助于确定它是否是远程计算机上的ssh问题.