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

Mac通过sshd连接VirtualBox Debian失败,报错原因及解决方法

解决Mac通过SSH连接VirtualBox中Debian的问题

嘿,你这是把两个搞混啦!sshd是SSH服务器的守护进程——它是用来在Debian上启动SSH服务的,可不是用来从Mac连接远程机器的客户端工具!你用sshd加连接参数,自然会报那些奇怪的错误。

下面一步步帮你搞定:

第一步:确保Debian的SSH服务正常运行

先登录VirtualBox里的Debian系统,打开终端做这些操作:

  • 如果还没装SSH服务器,先安装:
    sudo apt update && sudo apt install openssh-server -y
    
  • 检查服务状态,确认它在运行:
    sudo systemctl status sshd
    
    要是显示active (running)就没问题;没启动的话就手动启动:
    sudo systemctl start sshd
    
    怕下次开机又没启动?设置开机自启:
    sudo systemctl enable sshd
    

第二步:确认Debian的IP地址和网络可达性

VirtualBox的网络模式得设置对,不然Mac连不上Debian:

  1. 打开VirtualBox,选中你的Debian虚拟机,点「设置」→「网络」
  2. 把网络连接方式改成桥接适配器,然后选Mac当前在用的网卡(比如Wi-Fi)
  3. 回到Debian终端,查它的IP地址:
    ip a
    
    找到带inet开头的那行,比如inet 192.168.3.105,这就是你要连接的IP。

第三步:从Mac用正确的命令连接

回到Mac的终端,用ssh命令(不是sshd!)连接:

ssh root@192.xxx.xx.xx

如果提示「root登录被禁止」,这是Debian的默认安全设置,你可以:

  • 先登录普通用户,再切换到root:
    ssh your_debian_username@192.xxx.xx.xx
    
    登录后输入sudo su -就能切换到root权限。
  • 或者修改Debian的SSH配置允许root登录:
    在Debian里编辑配置文件:
    sudo nano /etc/ssh/sshd_config
    
    找到PermitRootLogin这一行,改成PermitRootLogin yes(如果想用密钥登录可以改成PermitRootLogin prohibit-password更安全),然后重启SSH服务:
    sudo systemctl restart sshd
    

第四步:连接成功后测试Telnet

在Debian终端里先装telnet工具:

sudo apt install telnet -y

之后就可以测试了,比如测试某个网站的80端口:

telnet example.com 80

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 07:20:06