查看服务端ssh是否启动

方式一:systemctl查看服务状态

[xy@xunye ~]$ systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since 日 2020-11-29 14:51:51 CST; 3 weeks 6 days ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1248 (sshd)
    Tasks: 1
   CGroup: /system.slice/sshd.service
           └─1248 /usr/sbin/sshd -D

11月 29 14:51:51 xunye systemd[1]: Starting OpenSSH server daemon...
11月 29 14:51:51 xunye sshd[1248]: Server listening on 0.0.0.0 port 22.
11月 29 14:51:51 xunye sshd[1248]: Server listening on :: port 22.
11月 29 14:51:51 xunye systemd[1]: Started OpenSSH server daemon.
12月 27 09:47:44 xunye sshd[13017]: Accepted password for xy from 192.168.0.103 port 5041 ssh2
12月 27 11:06:13 xunye sshd[14432]: Accepted password for xy from 192.168.0.103 port 4236 ssh2

方式二:查看socket 22号端口监听情况

[xy@xunye ~]$ netstat -anp | grep 22
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 192.168.0.104:22        192.168.0.103:4236      ESTABLISHED -                   
tcp6       0      0 :::22                   :::*                    LISTEN      

[xy@xunye ~]$ netstat -anp | grep ssh
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
unix  2      [ ACC ]     STREAM     LISTENING     44486    -                    /tmp/ssh-gDvgZ4vVQfUO/agent.3110
unix  2      [ ACC ]     STREAM     LISTENING     41423    -                    /run/user/1000/keyring/ssh

方式三:查看进程

[xy@xunye ~]$ ps -aux | grep sshd
root       1248  0.0  0.1 112924  4312 ?        Ss   11月29   0:00 /usr/sbin/sshd -D
root      14432  0.1  0.1 161012  5680 ?        Ss   11:06   0:00 sshd: xy [priv]
xy        14436  0.1  0.0 161164  2516 ?        S    11:06   0:00 sshd: xy@notty
xy        15035  0.0  0.0 112828   980 pts/3    S+   11:09   0:00 grep --color=auto sshd

猜你喜欢

转载自blog.csdn.net/xunye_dream/article/details/111773640
今日推荐