You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VirtualBox中两台Ubuntu服务器通信及SSH连接故障求助

Troubleshooting SSH Connectivity Between Two Ubuntu VirtualBox Servers

Alright, let’s work through this SSH issue step by step—since you’ve confirmed the servers can ping each other, we know the core network layer is working. That narrows things down to SSH-specific settings or firewall rules. Here’s what to check:

1. Confirm the SSH Service is Active

First, make sure the SSH daemon is running on both servers. On Ubuntu, run this to check status:

systemctl status sshd

If you see "inactive (dead)" in the output, start the service right away:

sudo systemctl start sshd

And set it to launch automatically on boot so you don’t have to repeat this later:

sudo systemctl enable sshd

2. Check Ubuntu’s Default Firewall (UFW)

Ubuntu uses UFW by default, and it might be blocking incoming SSH connections (port 22). Verify the current rules with:

sudo ufw status

If you don’t see a line allowing ssh or 22/tcp, add the rule:

sudo ufw allow ssh
# Or explicitly by port: sudo ufw allow 22/tcp

Then reload the firewall to apply changes:

sudo ufw reload

3. Inspect the SSH Configuration File

Sometimes SSH is configured to block certain connection types (like password login if you haven’t set up SSH keys yet). Open the config file with your preferred editor:

sudo nano /etc/ssh/sshd_config

Look for these critical settings and adjust them as needed:

  • PasswordAuthentication: Set to yes if you’re using a password to connect (switch back to no once you set up SSH keys for better security).
  • PermitRootLogin: If you’re trying to connect as root, set this to yes (or prohibit-password if using SSH keys).
  • ListenAddress: Ensure it’s set to 0.0.0.0 (listens on all network interfaces) or the server’s static IP address.

After making changes, restart the SSH service to apply them:

sudo systemctl restart sshd

4. Debug the Connection with Verbose Output

If the above steps don’t resolve the issue, run the SSH command with verbose mode to get detailed error messages—this will pinpoint exactly where the connection fails:

ssh -v your_username@192.168.1.111

Look for clues like "Connection refused" (points to service/firewall issues) or "Permission denied" (points to config or credential problems).

Quick VirtualBox Quirk Check

Even though ping works, double-check that your VirtualBox bridge adapter is attached to the correct physical network interface on your host machine (e.g., your active Wi-Fi or Ethernet adapter). You can confirm this in the VM’s settings > Network > Bridge Adapter > Name dropdown.


内容的提问来源于stack exchange,提问作者Dylan_

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:21:36