Windows SSH无法连接之“connection reset by ip_address port 22“问题解决

现象:ssh 链接服务器,报如下错误,链接不上

Connection reset by 10.251.130.26 port 22

 

查看Client的日志信息如下,没有明显的错误

 

C:\Users\lenovo>ssh -v sshd@10.251.130.26

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

debug1: Connecting to 10.251.130.26 [10.251.130.26] port 22.

debug1: Connection established.

debug1: identity file C:\\Users\\lenovo/.ssh/id_rsa type 0

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_rsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_dsa type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_dsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_ecdsa type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_ecdsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_ed25519 type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_ed25519-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_xmss type -1

debug1: key_load_public: No such file or directory

debug1: identity file C:\\Users\\lenovo/.ssh/id_xmss-cert type -1

debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7

debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_7.7

debug1: match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000

debug1: Authenticating to 10.251.130.26:22 as 'sshd'

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: algorithm: curve25519-sha256

debug1: kex: host key algorithm: ecdsa-sha2-nistp256

debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none

debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug1: Server host key: ecdsa-sha2-nistp256 SHA256:kjPpzO1sjwdv811Dyw33WJKrpolg1B61HVz0t+hGfH4

debug1: Host '10.251.130.26' is known and matches the ECDSA host key.

debug1: Found key in C:\\Users\\lenovo/.ssh/known_hosts:1

debug1: rekey after 134217728 blocks

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: rekey after 134217728 blocks

debug1: SSH2_MSG_EXT_INFO received

debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>

debug1: SSH2_MSG_SERVICE_ACCEPT received

Connection reset by 10.251.130.26 port 22

 

打开server的日志开关

打开文件C:\ProgramData\ssh\ sshd_config,修改SyslogFacility的配置如下

# Logging

SyslogFacility LOCAL0

#LogLevel INFO

 

重启SSH server的服务

 

客户端再进行访问,在路径下发现有日志文件sshd

C:\ProgramData\ssh\logs

 

打开文件发现报如下错误:

8696 2021-04-21 12:03:03.033 fatal: check_group_membership CheckTokenMembership for user sshd failed with 1309 for group administrators

 

找了网上找不到可能的原因,打开sshd用户的信息,发现其是管理员,但是不属于Administrators组。

所以想到的解决方案是换个用户试试,lenovo修改下密码,密码不能为空,再尝试连接,发现没有问题了。

其实是没有彻底解决问题,就是变通了一下,具体解决可能要看看怎么设置sshd的用户信息。

C:\Users\lenovo>ssh -v lenovo @10.251.130.26

………

………

lenovo@10.251.130.26's password:

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
根据提供的引用内容,"ssh连接Connection reset by peer"错误是由于网络问题引起的。通过排除法,可以确定这是一个网络问题。你可以使用一些工具来进一步排查,比如tcpdump和Wireshark进行抓包分析以查看网络通信是否正常。另外,引用提到了denyhosts工具可能会导致ip被拦截,所以你也可以检查是否启用了此工具并导致了连接问题。总结来说,ssh连接出现"Connection reset by peer"的错误通常是由网络问题引起的,可以通过使用适当的工具进行排查,如tcpdump和Wireshark,并检查是否启用了denyhosts工具。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [ECS云主机SSH连接提示“Connection reset by peer”的解决办法和解决思路](https://blog.csdn.net/weixin_33754065/article/details/85088444)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [远程SSH登陆服务器提示Connection reset by peer (已解决)](https://blog.csdn.net/RedaTao/article/details/102475743)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值