方法1、輸入setup命令查看系統(tǒng)服務(wù)配置
輸入setup
命令,選擇系統(tǒng)服務(wù)
,查看sshd
服務(wù)前面是否有 *
號(hào),有*
號(hào)表示已開(kāi)啟該服務(wù)。
服務(wù)前面有 *
號(hào)表示已開(kāi)啟該服務(wù)。
參考資料:https://www.bilibili.com/video/BV1dW411M7xL/?p=13
方法2、查看Linux系統(tǒng)是否開(kāi)通sshd服務(wù):systemctl status sshd.service或者service sshd status
如果該命令返回類似于active (running)
的結(jié)果,則表示sshd服務(wù)已經(jīng)在運(yùn)行中。
[root@sr var]# systemctl status sshd.service # 查看Linux系統(tǒng)是否開(kāi)通sshd服務(wù)
● 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系統(tǒng)是否開(kāi)通sshd服務(wù)
● 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、檢查服務(wù)器的22端口是否處于監(jiān)聽(tīng)狀態(tài)(SSH默認(rèn)使用22端口):netstat -tuln | grep 22或者netstat -an | grep 22
如果SSH服務(wù)已啟用,并且服務(wù)器正在監(jiān)聽(tīng)22端口,將顯示類似于0.0.0.0:22
或:::22
的信息。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-859313.html
[root@sr var]# netstat -tuln | grep 22 # 檢查服務(wù)器的22端口是否處于監(jiān)聽(tīng)狀態(tài)
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
[root@sr var]# netstat -an | grep 22 # 檢查服務(wù)器的22端口是否處于監(jiān)聽(tīng)狀態(tài)
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進(jìn)程:ps -ef | grep sshd
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-859313.html
[root@sr var]# ps -ef | grep sshd # 查看是否有 sshd 進(jìn)程
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
到了這里,關(guān)于Linux-如何查看Linux系統(tǒng)是否開(kāi)通sshd服務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!