zhoumobushangban 2022-06-06 10:10 采纳率: 50%
浏览 235
已结题

h3c防火墙 ssh request failed on channel 0

使用ssh时,把命令与登录拼在一起时,完成密码认证后,会报错“exec request failed on channel 0”。以下贴出debug.注意看最后,报出错误
ssh -v username@172.16.0.1 "dis cu"
[root@app1 ~]# ssh -v username@172.16.0.1 dir

OpenSSH_8.5p1, OpenSSL 1.0.2s 28 May 2019
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 172.16.0.1 [172.16.0.1] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type 0
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa_sk type -1
debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_ed25519_sk type -1
debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.5
debug1: Remote protocol version 2.0, remote software version Comware-7.1.064
debug1: compat_banner: no match: Comware-7.1.064
debug1: Authenticating to 172.16.0.1:22 as 'username'
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: 3des-cbc MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: 3des-cbc MAC: hmac-sha1 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<7680<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_GROUP received
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: SSH2_MSG_KEX_DH_GEX_REPLY received
debug1: Server host key: ssh-rsa SHA256:94V6il+RjoLL+tfgN1tRtIS55hgwFOV9tnqTUNNZQh4
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '172.16.0.1' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:6
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /root/.ssh/id_rsa RSA SHA256:u9nA509C/UOwsz2vwC0lKE52yaZPpOLMXXMmTGpf4RQ
debug1: Will attempt key: /root/.ssh/id_dsa
debug1: Will attempt key: /root/.ssh/id_ecdsa
debug1: Will attempt key: /root/.ssh/id_ecdsa_sk
debug1: Will attempt key: /root/.ssh/id_ed25519
debug1: Will attempt key: /root/.ssh/id_ed25519_sk
debug1: Will attempt key: /root/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received


  • Description:HuLianWangYeWu *
  • Any Unauthorized Login is Illegal !!! *

debug1: Authentications that can continue: password
debug1: Next authentication method: password
username@172.16.0.1's password:
debug1: Authentication succeeded (password).
Authenticated to 172.16.0.1 ([172.16.0.1]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: Sending command: dir
exec request failed on channel 0

如果是分开执行就可以, 登录时不拼接命令,先登录成功,然后输入命令 dir 这样就可以完美执行。

网络上搜索,都是说什么进程数太小。这个不能解释为什么分开执行就可以。再一个,我的目标机器是h3c防火墙,没有那些配置可以修改。
我目前的猜测是h3c防火墙设置了一些规则,防止ssh 跟命令拼在一起。

我在用java 使用jsch包 连接h3c防火墙,读取防火墙策略。但是在执行channel.connect(20000);这行代码时,就报错failed to send channel request。于是我就手动ssh 去执行。结果发现了上述现象。不知道是否有大佬知道这一情况。
  • 写回答

3条回答 默认 最新

  • 冰山76 2022-06-06 10:57
    关注

    命令执行太快,服务器未做出反应下条命令又来了,所以拼接命令一定要注意需要不需要服务器应答,如果不需要,则可以直接拼合,否则要注意设置

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月13日
  • 创建了问题 6月6日

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?