分页: 1 / 1

ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 14:56
桂花酒少年游
上周还能用装windows的新电脑通过ssh连接,昨天就不能连接了,但是昨天能被ping通。今天不能ssh也不能ping,ubuntu上运行ssh localhost没问题,也能上网。windows上显示 ssh: connect to host 192.168.31.129 port 22:Connection timed out.
krs@krs-Inspiron-3559:~$ sudo ufw status numbered
Status: active

To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 22 ALLOW IN Anywhere
[ 3] 80/tcp ALLOW IN Anywhere
[ 4] 22/tcp (v6) ALLOW IN Anywhere (v6)
[ 5] 22 (v6) ALLOW IN Anywhere (v6)
[ 6] 80/tcp (v6) ALLOW IN Anywhere (v6)
防火墙看22号端口也没问题啊。

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 14:59
astolia
你确定ubuntu机器的ip地址是192.168.31.129?

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:03
桂花酒少年游
astolia 写了: 2022-04-02 14:59 你确定ubuntu机器的ip地址是192.168.31.129?
确定 的我对了的
krs@krs-Inspiron-3559:~$ ifconfig | grep inet
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
inet 192.168.31.129 netmask 255.255.255.0 broadcast 192.168.31.255
inet6 fe80::8fe0:28a7:b7a1:172c prefixlen 64 scopeid 0x20<link>

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:18
astolia
检查过硬件没有?说不定是两方连接的路由器故障,你重启一下路由器呢?

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:26
桂花酒少年游
astolia 写了: 2022-04-02 15:18 检查过硬件没有?说不定是两方连接的路由器故障,你重启一下路由器呢?
现在是能用windows新电脑ping通 但是不能ssh,还是显示22端口连接超时 :Cry

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:29
astolia
那你看一下sshd是不是在监听22端口,sudo ss -ltnp 和 systemctl status sshd

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:31
桂花酒少年游
astolia 写了: 2022-04-02 15:29 那你看一下sshd是不是在监听22端口,sudo ss -ltnp 和 systemctl status sshd
krs@krs-Inspiron-3559:~$ sudo ss -ltnp | grep 22
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=817,fd=3))
LISTEN 0 70 127.0.0.1:33060 0.0.0.0:* users:(("mysqld",pid=901,fd=22))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=817,fd=4))
krs@krs-Inspiron-3559:~$ 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 2022-04-02 13:33:32 CST; 1h 57min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 817 (sshd)
Tasks: 1 (limit: 9260)
Memory: 4.9M
CGroup: /system.slice/ssh.service
└─817 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

Apr 02 13:33:32 krs-Inspiron-3559 systemd[1]: Starting OpenBSD Secure Shell server...
Apr 02 13:33:32 krs-Inspiron-3559 sshd[817]: Server listening on 0.0.0.0 port 22.
Apr 02 13:33:32 krs-Inspiron-3559 sshd[817]: Server listening on :: port 22.
Apr 02 13:33:32 krs-Inspiron-3559 systemd[1]: Started OpenBSD Secure Shell server.
Apr 02 14:24:42 krs-Inspiron-3559 sshd[13008]: Accepted password for krs from 127.0.0.1 port 54494 ssh2
Apr 02 14:24:42 krs-Inspiron-3559 sshd[13008]: pam_unix(sshd:session): session opened for user krs by (uid=0)

这是OBS占用了22端口吗?

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 15:46
astolia
你看一下windows机器分配的ip地址是什么,是不是和192.168.31.129在同一个子网。有可能是你的网络环境里有其他的dhcp服务器给你windows机器分配了其他的ip地址。
如果是在同一个子网,再到windows的命令行下面运行arp -a,看看192.168.31.129对应的mac地址是不是和ubuntu机器的一致,否则就是遭到了arp攻击

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 16:11
桂花酒少年游
astolia 写了: 2022-04-02 15:46 你看一下windows机器分配的ip地址是什么,是不是和192.168.31.129在同一个子网。有可能是你的网络环境里有其他的dhcp服务器给你windows机器分配了其他的ip地址。
如果是在同一个子网,再到windows的命令行下面运行arp -a,看看192.168.31.129对应的mac地址是不是和ubuntu机器的一致,否则就是遭到了arp攻击
大神,我重新连的我宿舍的网,windows的ip是10.60.194.138 子网掩码是255.255.224.0, ubuntu的是10.50.7.171 子网掩码是255.255.248.0。但是windows上使用arp -a没有ubuntu的这个ip,也没它的mac地址

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 16:17
astolia
桂花酒少年游 写了: 2022-04-02 16:11 大神,我重新连的我宿舍的网,windows的ip是10.60.194.138 子网掩码是255.255.224.0, ubuntu的是10.50.7.171 子网掩码是255.255.248.0。但是windows上使用arp -a没有ubuntu的这个ip,也没它的mac地址
我不知道你两台机器是怎么接的线,但这两台机器是被分配到了不同的局域网,不太可能相互连通。

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 16:21
桂花酒少年游
astolia 写了: 2022-04-02 16:17
桂花酒少年游 写了: 2022-04-02 16:11 大神,我重新连的我宿舍的网,windows的ip是10.60.194.138 子网掩码是255.255.224.0, ubuntu的是10.50.7.171 子网掩码是255.255.248.0。但是windows上使用arp -a没有ubuntu的这个ip,也没它的mac地址
我不知道你两台机器是怎么接的线,但这两台机器是被分配到了不同的局域网,不太可能相互连通。
我这个是移动的
Screenshot from 2022-04-02 16-20-01.png
Screenshot from 2022-04-02 16-20-01.png
路由器,ubuntu上设置了下网络,然后用了下clash翻墙

Re: ubuntu20.04物理机无法被ssh连接,也不能被ping通

发表于 : 2022-04-02 16:41
桂花酒少年游
找到问题了 我windows那边的ssh有问题不是ubuntu这边的问题,谢谢大神了