Virtual Box ssh 在 Virtual Box Ubuntu 机器上不起作用

Vla*_*eda 7 networking ssh virtualbox virtual-machine ubuntu

我安装了 Ubuntu 12.10,并在我的虚拟机中设置了 12.04 Server。

我的虚拟机可以访问互联网,我可以从我的主机 ping 它。

ping symfony.dev # points to 192.168.56.101, and successful ping.
Run Code Online (Sandbox Code Playgroud)

问题是我无法使用 SSH 连接到它

me@ubuntu:~$ ssh root@symfony.dev
ssh: connect to host symfony.dev port 22: Connection refused
me@ubuntu:~$ ssh -p 21 root@symfony.dev
ssh: connect to host symfony.dev port 21: Connection refused
Run Code Online (Sandbox Code Playgroud)

似乎没有IP冲突,如果我关闭机器,我将无法再ping该地址。

SSH 安装在虚拟机上(我确实尝试过sudo apt-get install openssh-server,但似乎这个包不存在,只有openssh-client- 已经安装,并且 ssh 可以从虚拟机运行)。

关于如何让它发挥作用的任何想法?

解决方案:

我需要安装openssh-server,但没有sshd.

sudo apt-get install sshd # next line won't work until you do this
sudo apt-get install openssh-server
Run Code Online (Sandbox Code Playgroud)

Geo*_*ell 5

  1. 在 VM 中,您可以通过 ssh 连接到 localhost 吗?如果没有,请检查您的 ssh 服务器。
  2. 如果您使用桥接模式进行网络连接,您可能需要访问 VirtualBox 设置并转发端口 22。本文有说明和屏幕截图。
  3. 是否在 VM 上运行防火墙?Ubuntu 附带ufw,因此请先尝试ufw status,然后再修改iptables.