如何在通道0上修复请求失败

问题描述 投票:58回答:14

当我想连接到我的服务器这样的时候

ssh -a [email protected] -p 22

它给了我两个错误消息:

PTY allocation request failed on channel 0
shell request failed on channel 0

当我使用参数-T时,第一条错误消息消失了。但是如何修复第二个呢?我无法连接。对于其他服务器,我可以毫无问题地连接。

我在MAC OS 10.9上参数-v向我展示了这个调试输出:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xxx.your-server.de [188.40.3.15] port 22.
debug1: Connection established.
debug1: identity file /Users/xxx/.ssh/id_rsa type -1
debug1: identity file /Users/xxx/.ssh/id_rsa-cert type -1
debug1: identity file /Users/xxx/.ssh/id_dsa type -1
debug1: identity file /Users/xxx/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version mod_sftp/0.9.8
debug1: no match: mod_sftp/0.9.8
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: Server host key: RSA 55:f5:ca:ca:01:45:0f:7b:71:0a:1f:ba:9e:25:17:fb
debug1: Host 'xxx.your-server.de' is known and matches the RSA host key.
debug1: Found key in /Users/xxx/.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,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/xxx/.ssh/id_rsa
debug1: Trying private key: /Users/xxx/.ssh/id_dsa
debug1: Next authentication method: password

输入密码后我得到了这个

debug1: Authentication succeeded (password).
Authenticated to xxx.your-server.de ([xxx.xxx.3.15]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = de_DE.UTF-8
shell request failed on channel 0
ssh terminal pty
14个回答
18
投票

通道0上的PTY分配请求失败

系统上有256个伪终端的限制。也许你有一个泄漏伪终端的应用程序。使用

lsof /dev/pts/*

看看哪些进程有开放的伪终端

通道0上的shell请求失败

我收到此错误(没有PTY分配错误)。事实证明,我的一个应用程序(QtCreator 3.0。?)正在泄露Zombie进程。其他用户能够登录,所以我可能已经达到我的每用户进程配额(如果有这样的事情)。我已更新到QtCreator 3.3。到现在为止还挺好。


0
投票

试试这个:

-T

0
投票

重新安装/ dev / pts适合我。你可以通过ssh远程执行此操作,如果你对受影响的机器运行这样的ssh。在运行这样的命令时,ssh不会请求tty,因此这将允许您远程重新安装/ dev / pts

ssh user @ host - 'mount -o remount,rw / dev / pts'


0
投票

我偶尔会在启动虚拟机时看到这一点。我们的自动化系统开始应用更新,因此根据时间安排可以更新关键包。

Upshot - 如果在目标计算机上更新ssh或其他相关软件包,则可能会发生这种情况。


0
投票

我在使用git bash时遇到了这个错误。我能够通过重新安装git for windows来解决这个问题。这个vi /etc/security/limits.d/20-nproc.conf * soft nproc 4096 # change to 65535 root soft nproc unlimited 的更多细节。


0
投票

我也遇到了同样的问题。只需重新启动我的服务器即可解决问题。


16
投票

卸载和装载/dev/pts为我工作

umount /dev/pts

mount devpts /dev/pts -t devpts

参考:http://www.iitk.ac.in/LDP/LDP/lfs/5.0/html/chapter06/proc.html


6
投票

只需将这些行添加到/etc/mtab/etc/fstab,然后重新启动系统即可。

none    /dev/pts    devpts    defaults    0    0

5
投票

我尝试通过ssh连接到我的服务器时遇到了完全相同的错误。我可以看到你正在使用Hetzner提供的服务器在端口22上连接它:

debug1:连接到xxx.your-server.de [188.40.3.15]端口22。

来自qazxsw poi的官方维基/文档说:

服务器/计算机(控制台)的加密远程诊断协议。要使用的SSH端口是222。

所以你必须通过端口222连接:

Hetzner

2
投票

我解决了一个类似的问题,我们的一个用户只用于ssh端口转发,因此他不需要访问PTY,并且在.ssh / authorized_keys文件中禁止它:

ssh -p 222 [email protected]

因此,当您尝试登录此用户时,仅显示消息

no-pty ssh-rsa AAA...nUB9 someuser

被退回了。因此,请检查用户的authorized_keys文件。


1
投票

从AWS控制台重新启动实例对我有用。有一项服务泄露了PTY allocation request failed on channel 0 帮助找到的文件连接。


1
投票

这是一个老问题,但如果有人像我一样来到这里......

这可能是服务器中错误日期的结果。如果您正在使用嵌入式系统,这可能是原因...所以检查您的日期:

lsof

1
投票

刚刚发现,我的情况是什么问题(提供者strato):我最后输出“shell请求在通道0上失败”时遇到了同样的问题。

我必须使用主密码和web-domain名称作为登录。 (德语www.wunschname.de,其中wunschname是您的网址。)

使用sftp用户名和相应密码的ssh登录没有成功。 (虽然scp和sftp适用于这些sftp用户!)


0
投票

$ date

意味着您没有shell或远程命令访问权限,修复服务器上的用户权限以获得shell访问权限,或者如果您只想要隧道使用shell request failed on channel 0-N选项

© www.soinside.com 2019 - 2024. All rights reserved.