当前位置:   article > 正文

ssh使用问题汇总_ssh reset by peer

ssh reset by peer

本文旨在为广大SSH用户提供一个全面而实用的使用问题汇总。我们将深入探讨SSH连接失败、密钥管理、权限设置等常见难题,并提供详细的解决方案。通过本文,您将能够轻松应对SSH使用过程中遇到的各类问题,提升SSH操作效率,保障远程连接的安全性。无论您是SSH初学者还是资深用户,相信本文都能为您提供有价值的参考和帮助。 

1. Connection reset by peer

现象

ssh到server时报如下错误

ssh_exchange_identification: read: Connection reset by peer

解决方法

  • 方法一:在sever端修改白名单
vim /etc/hosts.allow

添加

sshd : ALL

重启ssh服务 

service sshd restart
  • 方法二:在sever端修改黑名单
vim /etc/hosts.deny

把中含客户端IP的删除掉试试

重启ssh服务

service sshd restart

2. connection refused

现象

ssh: connect to host XX.XX.XX.XX port 22: Connection refused

解决方法

  • 方法一:检查目标主机的ssh server端程序是否安装、服务是否启动,是否在侦听22端口
ps -ef|grep sshd
  1. root 2859 1 020:29 ? 00:00:00 /usr/sbin/sshd -D
  2. root 2901 2859 020:31 ? 00:00:00 sshd: june[priv]
  3. june 2971 2901 020:31 ? 00:00:00 sshd:june@pts/1

其中/usr/sbin/sshd为ssh clinet/server中server端的守护进程,如果上述结果中没有sshd出现,那么可能就是你的server端程序没有安装,或者sshd服务没有启动

  • 方法二:本机是否设置了iptables规则,禁止了ssh的连入/连出
sudo iptables -L
  1. Chain INPUT (policy ACCEPT)
  2. target prot opt source destination
  3. ACCEPT tcp – anywhere anywhere tcp dpt:ssh
  4. Chain FORWARD (policy ACCEPT)
  5. target prot opt source destination
  6. Chain OUTPUT (policy ACCEPT)
  7. target prot opt source destination

3. SSL_ERROR_SYSCALL

现象

SSL_connect: SSL_ERROR_SYSCALL in connectiontogithub.com:443

原因分析

一般因为开了代理

解决方法

git config --global --unset http.proxy

4. Permission denied (publickey)

原因:本地禁止免密登录

 sudo vim /etc/ssh/sshd_config

找到PasswordAuthentication
将PasswordAuthentication no改为yes,保存
接着使用命令:

sudo service ssh restart 

原因:远端安全限制

The following method might work if you can access machineA and machineB independently (e.g. from machineC).

If ssh-copy-id is not working, password authentication could be disabled. The following is a workaround.

Having machineA's public key in machineB's authorized keys (i.e. ~/.ssh/authorized_keys) will allow you to ssh from machineA. This also applies to scp.

After generating the key pairs using: ssh-keygen

On machineA, execute cat ~/.ssh/id_rsa.pub

Sample output:

ssh-rsa AAAAB3NzaSGMFZW7yB anask@mahineA

Copy the printed key (⌘ Command+C, or CRTL+C) then add it to the ~/.ssh/authorized_keys file on machineB.

For example, execute the following on machineB:

echo 'ssh-rsa AAAAB3NzaSGMFZW7yB anask@mahineA' >> ~/.ssh/authorized_keys

参考文献

SSH登录提示:connection refused的解决办法_ABC_ORANGE的博客-CSDN博客
教你如何调试 SSH 连接

使用ssh远程连接服务器Permission denied (publickey). 解决方法_ssh publickey denied_IT鹅的博客-CSDN博客

server - SSH Permission denied (publickey) - Ask Ubuntu

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/711781
推荐阅读
相关标签
  

闽ICP备14008679号