ToB企服应用市场:ToB评测及商务社交产业平台

标题: Linux-怎样检察Linux体系是否开通sshd服务 [打印本页]

作者: 泉缘泉    时间: 2024-6-13 20:49
标题: Linux-怎样检察Linux体系是否开通sshd服务
方法1、输入setup命令检察体系服务配置

输入setup命令,选择体系服务,检察sshd服务前面是否有 *号,有*号表现已开启该服务。


服务前面有 *号表现已开启该服务。

参考资料:https://www.bilibili.com/video/BV1dW411M7xL/?p=13
方法2、检察Linux体系是否开通sshd服务:systemctl status sshd.service大概service sshd status

如果该命令返回类似于active (running)的效果,则表现sshd服务已经在运行中。

  1. [root@sr var]# systemctl status sshd.service                # 查看Linux系统是否开通sshd服务
  2. ● sshd.service - OpenSSH server daemon
  3.    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
  4.    Active: active (running) since Sat 2021-06-05 09:59:11 CST; 2 years 8 months ago
  5.      Docs: man:sshd(8)
  6.            man:sshd_config(5)
  7. Main PID: 1138 (sshd)
  8.     Tasks: 1
  9.    Memory: 7.8M
  10.    CGroup: /system.slice/sshd.service
  11.            └─1138 /usr/sbin/sshd -D
  12. Mar 01 11:29:45 sr sshd[17514]: Did not receive identification string from XXX.XXX.XXX.XXX port 43992
  13. Mar 01 12:01:05 sr sshd[20428]: Did not receive identification string from XXX.XXX.XXX.XXX port 59472
  14. Mar 01 12:39:53 sr sshd[23931]: Connection closed by XXX.XXX.XXX.XXX port 52504 [preauth]
  15. Mar 01 12:39:55 sr sshd[23934]: Connection closed by XXX.XXX.XXX.XXX port 52518 [preauth]
  16. Mar 01 12:39:56 sr sshd[23937]: Connection closed by XXX.XXX.XXX.XXX port 52524 [preauth]
  17. Mar 01 13:59:54 sr sshd[31209]: Did not receive identification string from XXX.XXX.XXX.XXX port 64001
  18. Mar 01 14:52:51 sr sshd[3621]: Did not receive identification string from XXX.XXX.XXX.XXX port 57980
  19. Mar 01 16:01:59 sr sshd[10113]: Accepted password for root from XXX.XXX.XXX.XXX port 18389 ssh2
  20. Mar 01 16:42:55 sr sshd[13858]: Connection closed by XXX.XXX.XXX.XXX port 36434 [preauth]
  21. Mar 01 16:44:21 sr sshd[14021]: Did not receive identification string from XXX.XXX.XXX.XXX port 10000
  22. [root@sr var]# service sshd status                # 查看Linux系统是否开通sshd服务
  23. ● sshd.service - OpenSSH server daemon
  24.    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
  25.    Active: active (running) since Sat 2021-06-05 09:59:11 CST; 2 years 8 months ago
  26.      Docs: man:sshd(8)
  27.            man:sshd_config(5)
  28. Main PID: 1138 (sshd)
  29.     Tasks: 1
  30.    Memory: 7.8M
  31.    CGroup: /system.slice/sshd.service
  32.            └─1138 /usr/sbin/sshd -D
  33. Mar 01 11:29:45 sr sshd[17514]: Did not receive identification string from XXX.XXX.XXX.XXX port 43992
  34. Mar 01 12:01:05 sr sshd[20428]: Did not receive identification string from XXX.XXX.XXX.XXX port 59472
  35. Mar 01 12:39:53 sr sshd[23931]: Connection closed by XXX.XXX.XXX.XXX port 52504 [preauth]
  36. Mar 01 12:39:55 sr sshd[23934]: Connection closed by XXX.XXX.XXX.XXX port 52518 [preauth]
  37. Mar 01 12:39:56 sr sshd[23937]: Connection closed by XXX.XXX.XXX.XXX port 52524 [preauth]
  38. Mar 01 13:59:54 sr sshd[31209]: Did not receive identification string from XXX.XXX.XXX.XXX port 64001
  39. Mar 01 14:52:51 sr sshd[3621]: Did not receive identification string from XXX.XXX.XXX.XXX port 57980
  40. Mar 01 16:01:59 sr sshd[10113]: Accepted password for root from XXX.XXX.XXX.XXX port 18389 ssh2
  41. Mar 01 16:42:55 sr sshd[13858]: Connection closed by XXX.XXX.XXX.XXX port 36434 [preauth]
  42. Mar 01 16:44:21 sr sshd[14021]: Did not receive identification string from XXX.XXX.XXX.XXX port 10000
复制代码
方法3、查抄服务器的22端口是否处于监听状态(SSH默认使用22端口):netstat -tuln | grep 22大概netstat -an | grep 22

如果SSH服务已启用,而且服务器正在监听22端口,将显示类似于0.0.0.0:22或:::22的信息。

  1. [root@sr var]# netstat -tuln | grep 22                # 检查服务器的22端口是否处于监听状态
  2. tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
  3. [root@sr var]# netstat -an | grep 22                # 检查服务器的22端口是否处于监听状态
  4. tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
  5. tcp        0      0 127.0.0.1:60119         127.0.0.1:35322         TIME_WAIT  
  6. tcp        0     52 XXX.XXX.XXX.XXX:22        XXX.XXX.XXX.XXX:18389    ESTABLISHED
  7. tcp        0      0 XXX.XXX.XXX.XXX:39116     XXX.XXX.XXX.XXX:60101   ESTABLISHED
  8. tcp        0      0 XXX.XXX.XXX.XXX:32792     XXX.XXX.XXX.XXX:60101   ESTABLISHED
  9. unix  2      [ ACC ]     STREAM     LISTENING     12258    /run/dbus/system_bus_socket
  10. unix  2      [ ]         DGRAM                    14221   
  11. unix  3      [ ]         STREAM     CONNECTED     21885622
复制代码
方法4、检察是否有sshd进程:ps -ef | grep sshd


  1. [root@sr var]# ps -ef | grep sshd                # 查看是否有 sshd 进程
  2. root      1138     1  0  2021 ?        00:01:18 /usr/sbin/sshd -D
  3. root     10113  1138  0 16:01 ?        00:00:00 sshd: root@pts/0
  4. root     18104 10115  0 17:27 pts/0    00:00:00 grep --color=auto sshd
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4