首先使用ping工具,看看网络是不是通的,基础简单方式,不是充分必要条件
也可以使用telnet工具,注意没有冒号
cet@edge3204069539:~$ ping 10.12.135.74
ping: socket: 不允许的操作
cet@edge3204069539:~$ telnet 10.12.135.74 22
没有ping工具的可以Install一下
安装后还是ping不通,查看防火墙出入站规则有没有开放端口
查看ssh服务状态,有没有安装SSH-Server和SSH-Client
systemctl status sshd
已经安装的响应
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-01-30 09:51:50 CST; 12min ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 877 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 892 (sshd)
Tasks: 1 (limit: 19071)
Memory: 3.9M
CGroup: /system.slice/ssh.service
└─892 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
1月 30 09:51:50 cet-vm systemd[1]: Starting OpenBSD Secure Shell server...
1月 30 09:51:50 cet-vm sshd[892]: Server listening on 0.0.0.0 port 22.
1月 30 09:51:50 cet-vm sshd[892]: Server listening on :: port 22.
1月 30 09:51:50 cet-vm systemd[1]: Started OpenBSD Secure Shell server.
1月 30 09:58:17 cet-vm sshd[2899]: Accepted password for cet from 10.12.135.74 port 53811 ssh2
1月 30 09:58:17 cet-vm sshd[2899]: pam_unix(sshd:session): session opened for user cet by (uid=0)
未安装的响应
Unit sshd.service could not be found.
因为是用SSH工具去连接虚拟机,虚拟机应该是提供服务的一方
apt-get install openssh-server
解决问题