2016年6月28日星期二

ssh: connect to host localhost port 22: Connection refused 问题解决

ssh: connect to host localhost port 22: Connection refused 问题解决

问题描述:centos7 服务器出现ssh经常掉线,git拉取代码,上传出现ssh: connect to host localhost port 22: Connection refused 错误,同时还会报“Write failed: Broken pipe” 错误。

解决:思路如下:
首先【service sshd status】检查ssh服务启动没。

然后【netstat -nlap | grep ":22"】检查端口启动没。

接着【telnet 127.0.0.1 22】看看本地能连上不。

然后看看防火墙有没有启动,以及有没有开放sshd的tcp22端口。老版本的命令是【service iptables status】,请自行搜索新版本命令。

最后去客户机上ping一下这台服务器看看能否ping通,如果禁ping那就只能做【telnet 服务器IP 22】了。

如果都通了,还要去服务器上检查一下sshd是否设置了开机启动。老版本的命令是【chkconfig --lish | grep sshd】,请自行搜索新版本命令。如果都是off那就【chkconfig sshd on】。

最后检测出来是ip地址冲突导致,因为ping到windows系统是一般是128,linux系统一般是64



参考:
https://www.zhihu.com/question/47897094/answer/108152381?group_id=731288531665682432#comment-146036784

没有评论:

发表评论