ssh: connect to host localhost port 22: Connection refused

    xiaoxiao2021-03-26  15

    ssh localhost  错误信息为:ssh: connect to host localhost port 22: Connection refused  这种错误很主要的一个原因是sshd服务没有启动,先启动sshd服务后就没有问题了    www.2cto.com   1、查卡服务是否启用  ps -ef | grep ssh    2、如果没有启用 则要安装  yum install openssh-server    3、安装完之后开启  /etc/init.d/sshd start  如果/etc/init.d/sshd start出现:  Generating SSH1 RSA host key:                              [FAILED]    www.2cto.com   解决办法:  $ yum search openssh  $ sudo yum install openssh  $ sudo sshd service start  sshd re-exec requires execution with an absolute path  [honki@localhost ~]$ sudo service sshd start  Generating SSH1 RSA host key:                              [  OK  ]  Generating SSH2 RSA host key:                              [  OK  ]  Generating SSH2 DSA host key:                              [  OK  ]  Starting sshd:                                             [  OK  ]    4、如果还是连不上 关闭防火墙  /etc/init.d/iptables stop  以上4步都是大部分人遇到的问题,到这里基本上都解决了,但是还有一种情况网上很多人没有遇到过,是我本人亲测出来的 就是ssh localhost可以进去,ssh 主机名不可以, 解决方法:vi /etc/hosts里添加ip  hostname映射关系   如此即可。
    转载请注明原文地址: https://ju.6miu.com/read-650002.html

    最新回复(0)