第一次无法连接到Github

n0p*_*0pe 3 linux terminal git opensuse github

这是我第一次使用 Git,我正在尝试在我的盒子上设置它。我在 Github 网络界面中将我的密钥添加到我的个人资料中。当我尝试连接时...:

max@linux-vwzy:~> ssh git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is xx
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0

max@linux-vwzy:~> ssh-add ~/.ssh/id_rsa
Identity added: /home/max/.ssh/id_rsa (/home/max/.ssh/id_rsa)

max@linux-vwzy:~> ssh git@github.com
PTY allocation request failed on channel 0
Run Code Online (Sandbox Code Playgroud)

我应该会收到某种欢迎信息,但我没有。

Chr*_*sen 8

当您ssh git@github.com在普通终端环境中运行时,您的 SSH 客户端(您本地机器上的ssh进程)将从服务器请求一个伪终端 (pty)。

GitHub 一直拒绝 pty 分配。

如果服务器拒绝其 pty 分配请求,OpenSSH ssh 的旧版本(5.6 之前)将“回退”到 no-pty 模式。

如果服务器拒绝其 pty 分配请求,则较新版本(5.6 到 5.8)的 OpenSSH ssh 将中止。

如果 pty 分配是自动完成的,OpenSSH 的ssh的最新版本(5.9 和更高版本)将采取前一种操作(继续),如果有对 pty 的显式请求(-t给定或RequestTTY等于yes/ force),则后一种操作(中止) .

您可以使用以下选项告诉ssh(旧的或新的)避免请求 pty 分配-T

ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)

然后您应该会看到 GitHub 消息:

你好 <用户名>!您已成功通过身份验证,但 GitHub 不提供 shell 访问。


来自OpenSSH 5.6 发布公告

  • 当 pty 分配请求失败时终止通道。修复了服务器拒绝 pty 分配时卡住的客户端 (bz#1698)

bz#1698似乎是对“便携式 OpenSSH” Bugzilla 中记录报告的引用。


来自OpenSSH clientloop.c rev 1.234的签入消息:

改进我们在 TTY 分配失败时的行为:如果我们处于 RequestTTY=auto 模式(默认),那么不要将 TTY 分配错误视为致命错误,而只是将本地 TTY 恢复到熟模式并继续。这在从不分配 TTY 的设备上更为优雅。

如果 RequestTTY 设置为“yes”或“force”,则无法分配 TTY 是致命的。