无法从 Machine2 ssh 到 Machine1

无法从 Machine2 ssh 到 Machine1

我正在尝试从我的 ubuntu VM2 ssh 到 ubuntu VM1。Ping 工作正常且 ssh 处于活动状态,ufw 也处于活动状态。但是 ssh 命令超时。

ssh user@Machine1_ip_address(发生超时)

Machine2 的状态如下:

    osboxes@osboxes:~/virt-utils$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.12  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::b5a8:7e0f:1980:254f  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:31:40:2c  txqueuelen 1000  (Ethernet)
        RX packets 388285  bytes 563502310 (563.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 99408  bytes 10177352 (10.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2009  bytes 281204 (281.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2009  bytes 281204 (281.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

osboxes@osboxes:~/virt-utils$ sudo ufw status
[sudo] password for osboxes:
Status: active
osboxes@osboxes:~/virt-utils$ service sshd status
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled;
   Active: active (running) since Sun 2019-11-17 12:41:19 ES
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 29449 ExecStartPre=/usr/sbin/sshd -t (code=exited
 Main PID: 29466 (sshd)
    Tasks: 1 (limit: 4544)
   Memory: 1.2M
   CGroup: /system.slice/ssh.service
           └─29466 /usr/sbin/sshd -D

Nov 17 12:41:19 osboxes systemd[1]: Starting OpenBSD Secure
Nov 17 12:41:19 osboxes sshd[29466]: Server listening on 0.0
Nov 17 12:41:19 osboxes sshd[29466]: Server listening on ::
Nov 17 12:41:19 osboxes systemd[1]: Started OpenBSD Secure S
lines 1-16/16 (END)
osboxes@osboxes:~/virt-utils$

请有人指导我如何解决这个问题。我在所有虚拟机上都使用桥接网络。

祖尔菲。

答案1

要允许 ssh,运行

sudo ufw allow ssh

这将允许 ssh 的默认端口 (22)。

了解更多信息,DigitalOcean 有一个相当不错的 UFW 指南

相关内容