午夜稻草人

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

问题分析

vmware配置的fedora虚拟机, 主机能ping通虚拟机, 虚拟机也能ping通主机。但是用PUTTY连接虚拟机的时候出现 Network error: Connection refused。

排查方法

1、查看SSH服务有没有安装

        #rpm -qa | grep ssh

[root@localhost ~]# rpm -qa|grep ssh
openssh-clients-6.1p1-4.fc18.i686
openssh-6.1p1-4.fc18.i686
libssh2-1.4.2-2.fc18.i686
openssh-server-6.1p1-4.fc18.i686

     2、查看SSH服务有没有开启

       #/bin/systemctl status  sshd.service

sshd.service - OpenSSH server daemon
          Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
          Active: active (running) since Wed, 2018-12-19 07:45:03 EST; 2h 1min ago
         Process: 687 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
        Main PID: 695 (sshd)
          CGroup: name=systemd:/system/sshd.service
                  └ 695 /usr/sbin/sshd -D

Dec 19 07:45:03 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
Dec 19 07:45:03 localhost.localdomain sshd[695]: Server listening on 0.0.0.0 port 22.
Dec 19 07:45:03 localhost.localdomain sshd[695]: Server listening on :: port 22.
Dec 19 08:41:30 localhost.localdomain sshd[14675]: Nasty PTR record "192.168.2.1" is set up for 192.168.2.1, ignoring
Dec 19 08:41:32 localhost.localdomain sshd[14675]: Accepted password for root from 192.168.2.1 port 8883 ssh2

   如果没有开启sshd

  #/bin/systemctl start sshd.service

  #/bin/systemctl enable sshd.service

   3、查看所有的端口

       #netstat  -tlnp      

[root@localhost init.d]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State                                               PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN                                              686/rpcbind
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN                                              695/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN                                              14031/sendmail: acc
tcp6       0      0 :::111                  :::*                    LISTEN                                              686/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN                                              695/sshd

     4、查看ssh使用的22号端口有没有enable

        #netstat -an|grep 22  

[root@localhost init.d]# netstat -an|grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 192.168.2.10:22         192.168.2.1:8883        ESTABLISHED
tcp        0      0 192.168.2.10:22         192.168.2.1:10291       ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
unix  3      [ ]         STREAM     CONNECTED     16822
unix  3      [ ]         STREAM     CONNECTED     14221    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     18622
unix  3      [ ]         STREAM     CONNECTED     16722    /var/run/dbus/system_bus_socket

     5、采用SSH能不能正常连接

        #ssh root@192.168.2.10

[root@localhost init.d]# ssh root@192.168.2.10
The authenticity of host '192.168.2.10 (192.168.2.10)' can't be established.
RSA key fingerprint is dd:bc:ab:9f:46:e9:7a:e8:47:37:41:3b:3e:af:a4:25.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.10' (RSA) to the list of known hosts.
Last login: Wed Dec 19 09:52:01 2018 from 192.168.2.1

   6、把Linux防火墙都关闭

[root@localhost ~]# /bin/systemctl status  iptables.service
iptables.service - IPv4 firewall with iptables
          Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled)
          Active: inactive (dead)
          CGroup: name=systemd:/system/iptables.service

 

posted on 2018-12-19 22:58  午夜稻草人  阅读(4003)  评论(0编辑  收藏  举报