Linux 能 ping 通,但是 ssh 登陆不上
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
·
问题描述
刚刚在本地装了ubuntu虚拟机,发现本地本机能ping通虚拟机网络
$ ping 172.16.0.4
PING 172.16.0.4 (172.16.0.4): 56 data bytes
64 bytes from 172.16.0.4: icmp_seq=0 ttl=64 time=0.385 ms
64 bytes from 172.16.0.4: icmp_seq=1 ttl=64 time=0.775 ms
64 bytes from 172.16.0.4: icmp_seq=2 ttl=64 time=0.697 ms
172.16.0.4为ubuntu虚拟机ip,接着使用ssh命令尝试登录服务器
$ ssh root@172.16.0.4
ssh: connect to host 172.16.0.4 port 22: Connection refused
问题分析
本地能ping通虚拟机,证明虚拟机与本机之间的网络连接没问题。那么就有可能是ssh服务的问题,在虚拟机中使用telnet尝试连接22端口
$ telnet 127.0.0.1 22
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
发现22端口连接不上,此时有可能是ssh服务未启动,查看ssh服务状态
$ systemctl status sshd
● sshd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
No such file or directory 表示没安装该服务
问题解决
安装ssh服务
$ sudo apt-get install openssh-server
安装完openssh-server,再次查看sshd服务状态
$ systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-02-20 04:07:24 PST; 17min ago
Main PID: 6437 (sshd)
CGroup: /system.slice/ssh.service
└─6437 /usr/sbin/sshd -D
Feb 20 04:07:24 172 systemd[1]: Starting OpenBSD Secure Shell server...
Feb 20 04:07:24 172 sshd[6437]: Server listening on 0.0.0.0 port 22.
Feb 20 04:07:24 172 sshd[6437]: Server listening on :: port 22.
Feb 20 04:07:24 172 systemd[1]: Started OpenBSD Secure Shell server.
此时sshd服务正常启动,本机再次使用ssh登陆到虚拟机
$ ssh root@172.16.0.4
root@172.16.0.4's password:
要求输入密码,证明ssh服务正常,问题解决

A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)