ssh: connect to host 192.168.56.101 port 22: Connection refused

重启centos7的虚拟机之后在本地进行ssh连接出现了如题的bug。
22号端口没有开放。
其实22号端口是随着ssh server的启动而开放的,不需要也不能手动打开。因为它依赖的不是tcp而是ssh协议。
这时候一般可以重启sshd。
在centos6下

service start ssh

在centos7下

systemctl start sshd 

要是还不行,很有可能sshd会启动失败,如果这样,那就重装吧,这样基本可以解决问题:

yum remove openssh
yum install openssh openssh-server openssh-clients
service sshd start
(systemctl start sshd)

猜你喜欢

转载自blog.csdn.net/qq_42229092/article/details/107875593