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服务已经在运行中。
在这里插入图片描述

[root@sr var]# systemctl status sshd.service		# 查看Linux系统是否开通sshd服务
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-06-05 09:59:11 CST; 2 years 8 months ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1138 (sshd)
    Tasks: 1
   Memory: 7.8M
   CGroup: /system.slice/sshd.service
           └─1138 /usr/sbin/sshd -D

Mar 01 11:29:45 sr sshd[17514]: Did not receive identification string from XXX.XXX.XXX.XXX port 43992
Mar 01 12:01:05 sr sshd[20428]: Did not receive identification string from XXX.XXX.XXX.XXX port 59472
Mar 01 12:39:53 sr sshd[23931]: Connection closed by XXX.XXX.XXX.XXX port 52504 [preauth]
Mar 01 12:39:55 sr sshd[23934]: Connection closed by XXX.XXX.XXX.XXX port 52518 [preauth]
Mar 01 12:39:56 sr sshd[23937]: Connection closed by XXX.XXX.XXX.XXX port 52524 [preauth]
Mar 01 13:59:54 sr sshd[31209]: Did not receive identification string from XXX.XXX.XXX.XXX port 64001
Mar 01 14:52:51 sr sshd[3621]: Did not receive identification string from XXX.XXX.XXX.XXX port 57980
Mar 01 16:01:59 sr sshd[10113]: Accepted password for root from XXX.XXX.XXX.XXX port 18389 ssh2
Mar 01 16:42:55 sr sshd[13858]: Connection closed by XXX.XXX.XXX.XXX port 36434 [preauth]
Mar 01 16:44:21 sr sshd[14021]: Did not receive identification string from XXX.XXX.XXX.XXX port 10000
[root@sr var]# service sshd status		# 查看Linux系统是否开通sshd服务
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-06-05 09:59:11 CST; 2 years 8 months ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1138 (sshd)
    Tasks: 1
   Memory: 7.8M
   CGroup: /system.slice/sshd.service
           └─1138 /usr/sbin/sshd -D

Mar 01 11:29:45 sr sshd[17514]: Did not receive identification string from XXX.XXX.XXX.XXX port 43992
Mar 01 12:01:05 sr sshd[20428]: Did not receive identification string from XXX.XXX.XXX.XXX port 59472
Mar 01 12:39:53 sr sshd[23931]: Connection closed by XXX.XXX.XXX.XXX port 52504 [preauth]
Mar 01 12:39:55 sr sshd[23934]: Connection closed by XXX.XXX.XXX.XXX port 52518 [preauth]
Mar 01 12:39:56 sr sshd[23937]: Connection closed by XXX.XXX.XXX.XXX port 52524 [preauth]
Mar 01 13:59:54 sr sshd[31209]: Did not receive identification string from XXX.XXX.XXX.XXX port 64001
Mar 01 14:52:51 sr sshd[3621]: Did not receive identification string from XXX.XXX.XXX.XXX port 57980
Mar 01 16:01:59 sr sshd[10113]: Accepted password for root from XXX.XXX.XXX.XXX port 18389 ssh2
Mar 01 16:42:55 sr sshd[13858]: Connection closed by XXX.XXX.XXX.XXX port 36434 [preauth]
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的信息。
在这里插入图片描述

[root@sr var]# netstat -tuln | grep 22		# 检查服务器的22端口是否处于监听状态
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
[root@sr var]# netstat -an | grep 22		# 检查服务器的22端口是否处于监听状态
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:60119         127.0.0.1:35322         TIME_WAIT  
tcp        0     52 XXX.XXX.XXX.XXX:22        XXX.XXX.XXX.XXX:18389    ESTABLISHED
tcp        0      0 XXX.XXX.XXX.XXX:39116     XXX.XXX.XXX.XXX:60101   ESTABLISHED
tcp        0      0 XXX.XXX.XXX.XXX:32792     XXX.XXX.XXX.XXX:60101   ESTABLISHED
unix  2      [ ACC ]     STREAM     LISTENING     12258    /run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    14221    
unix  3      [ ]         STREAM     CONNECTED     21885622

方法4、查看是否有sshd进程:ps -ef | grep sshd

在这里插入图片描述

[root@sr var]# ps -ef | grep sshd		# 查看是否有 sshd 进程
root      1138     1  0  2021 ?        00:01:18 /usr/sbin/sshd -D
root     10113  1138  0 16:01 ?        00:00:00 sshd: root@pts/0
root     18104 10115  0 17:27 pts/0    00:00:00 grep --color=auto sshd
  • 11
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值