1.查看 ssh 是否启动。
service sshd status
root@VM-24-15-centos project]# service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-01-06 10:05:34 CST; 1 months 29 days ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 1844 (sshd)
CGroup: /system.slice/sshd.service
├─1844 /usr/sbin/sshd -D
├─5559 sshd: [accepted]
├─5560 sshd: [net]
├─5849 sshd: [accepted]
└─5851 sshd: [net]
2.查看 ssh端口
netstat -tnlp | grep ssh
[root@VM-24-15-centos project]# netstat -tnlp | grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1844/sshd
tcp6 0 0 :::22 :::* LISTEN 1844/sshd
# 或者 netstat -lnatp | grep sshdrep sshd
[root@VM-24-15-centos project]# netstat -lnatp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1844/sshd
tcp 0 52 10.0.24.15:22 114.249.198.159:2027 ESTABLISHED 1191/sshd: root@pts
tcp 0 0 10.0.24.15:22 114.249.198.159:2039 ESTABLISHED 1209/sshd: root@not
tcp 0 0 10.0.24.15:22 114.249.198.159:2192 ESTABLISHED 8989/sshd: root@not
tcp 0 0 10.0.24.15:22 114.249.198.159:2191 ESTABLISHED 8974/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1844/sshd
3.重启 ssh 服务
/etc/init.d/sshd restart # 或者 service sshd start
4.检查防火墙是否关闭
5.如果以上都不行就看看是否安装 ssh(CentOS7.5)
# 检查是否有安装包 rpm -qa | grep ssh # centos 安装 yum install openssh-server # ubuntu 安装 sudo apt-get install openssh-server