首页 > 代码库 > 查看ssh服务开启状态
查看ssh服务开启状态
root@dbaudit-desktop:/etc/init.d# /etc/init.d/ssh status
* sshd is running
或者这样检查:root@dbaudit-desktop:/etc/init.d# service ssh status
ssh start/running, process 748
或者这样检查:
root@dbaudit-desktop:~# netstat -apntlu
激活Internet连接 (服务器和已建立连接的)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 26913/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1239/cupsd
tcp 0 0 0.0.0.0:636 0.0.0.0:* LISTEN 1139/slapd
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 1139/slapd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 731/mysqld
tcp 0 0 192.168.51.95:49362 192.168.51.207:22 ESTABLISHED 3763/ssh
tcp 0 0 192.168.51.95:49363 192.168.51.207:22 ESTABLISHED 3788/ssh
tcp 0 0 192.168.51.95:22 192.168.51.113:5419 ESTABLISHED 25662/3
tcp6 0 0 :::80 :::* LISTEN 1361/apache2
tcp6 0 0 :::22 :::* LISTEN 26913/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1239/cupsd
tcp6 0 0 :::636 :::* LISTEN 1139/slapd
tcp6 0 0 :::389 :::* LISTEN 1139/slapd
udp 0 0 0.0.0.0:50138 0.0.0.0:* 764/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 764/avahi-daemon: r
或者这样检查:
root@dbaudit-desktop:~# ps -ef | grep ssh
root 2217 2181 0 08:48 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session
root 3669 3625 0 08:58 pts/1 00:00:00 ssh root@192.168.51.207
root 3680 2403 0 08:58 pts/0 00:00:00 ssh root@192.168.51.207
root 3763 2403 0 08:59 pts/0 00:00:00 ssh root@192.168.51.207
root 3788 3625 0 08:59 pts/1 00:00:00 ssh root@192.168.51.207
root 25662 1 0 11:53 ? 00:00:00 sshd: root@pts/3
root 26003 1 0 11:54 ? 00:00:00 /usr/sbin/sshd
root 26153 25890 0 11:55 pts/3 00:00:00 grep --color=auto ssh
或者直接用putty看看能不能连接上。注意:关闭远程协助服务后,本次putty登录并不自动断开,但尝试再次登录putty则不会登录上去了。
查看ssh服务开启状态