按照标准路线图设置 github 环境后,我立即遇到错误。我希望看到这些问题得到澄清。在终端吐出的代码乱码后,我在下面提出了一个更详细的问题。
我创建 SSH 密钥对的步骤如下:
ssh-keygen -t rsa -C "[email protected]"
测试连接
ssh [email protected]
测试的输出是:
PTY allocation request failed on channel 0
我不知道这是什么意思,但据我了解 -v 标志将输出调试信息
ssh -v [email protected]
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /Users/redres/.ssh/id_rsa type 1
debug1: identity file /Users/redres/.ssh/id_rsa-cert type -1
debug1: identity file /Users/redres/.ssh/id_dsa type -1
debug1: identity file /Users/redres/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 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/redres/.ssh/known_hosts:1
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/redres/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([204.232.175.90]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Remote: Forced command: gerve Richnl a7:d7:de:d3:80:a9:9f:be:02:88:74:50:0c:1e:5e:bc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command: gerve Richnl a7:d7:de:d3:80:a9:9f:be:02:88:74:50:0c:1e:5e:bc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LC_CTYPE =
PTY allocation request failed on channel 0
这并没有给我任何有用的东西,因为我不理解其中的大部分内容,但在谷歌搜索后,我使用了 -vT 标志,输出如下
ssh -vT [email protected]
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /Users/redres/.ssh/id_rsa type 1
debug1: identity file /Users/redres/.ssh/id_rsa-cert type -1
debug1: identity file /Users/redres/.ssh/id_dsa type -1
debug1: identity file /Users/redres/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 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/redres/.ssh/known_hosts:1
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/redres/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([204.232.175.90]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Remote: Forced command: gerve Richnl a7:d7:de:d3:80:a9:9f:be:02:88:74:50:0c:1e:5e:bc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command: gerve Richnl a7:d7:de:d3:80:a9:9f:be:02:88:74:50:0c:1e:5e:bc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LC_CTYPE =
Hi Richnl! You've successfully authenticated, but GitHub does not provide shell access.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2384, received 2936 bytes, in 0.3 seconds
Bytes per second: sent 7295.9, received 8985.2
debug1: Exit status 1
因为我可以过滤掉所有论坛和 git 本身,所以你可以忽略“shell 访问错误”,因为你反正也不需要它
我想知道,这是否是正确的输出?有人能向我解释一下什么是 PYT 和 T 标志吗?因为它们在这方面起着核心作用。官方文档中也没有使用 -T 标志。
请理解这一点,而不仅仅是输入愚蠢的按键
提前致谢
我从以下步骤中得到了其他步骤教程
答案1
在 Linux 和类似系统上,“PTY”或伪 TTY 是用于运行交互式命令行程序的特殊设备;它们就像虚拟显示器/屏幕,只是只显示文本。您打开的每个新 Xterm 或 iTerm 或 Konsole 窗口都有自己的 PTY。程序将文本写入该 PTY,终端将其绘制在屏幕上。对于每个交互式 SSH 连接,服务器也使用 PTY。
但是,Github 的 SSH 服务器不提供任何交互式服务 - 它们仅允许推送和获取 Git 存储库,这不需要或尝试分配 PTY;它只是一个简单的数据流。这意味着服务器可以为帐户禁用 PTY 分配git@
。
当您运行 时,您的 SSH 客户端认为您将打开一个交互式连接,因此它会要求服务器为其分配一个 PTY。由于服务器不允许分配 PTY,因此会打印错误消息。该选项用于告诉您的客户端永远不要在服务器上请求 PTY。ssh [email protected]
-T
ssh
但无论您使用什么都无关紧要,因为无论如何您都不会获得交互式 shell – 服务器配置为仅打印出问候消息并断开连接。ssh [email protected]
ssh -T [email protected]
换句话说,唯一一次曾经手动连接到 Github 是在测试连接时。其余时间,连接将由您的git
工具建立,这些工具永远不会使用 PTY,因此错误消息和-T
选项都无关紧要。
$ ssh[电子邮件保护] PTY 分配请求失败 你好,grawity!你已成功验证,但 GitHub 不提供 shell 访问权限。 $