Virtualbox- 在 Headless 模式下运行时无法访问 VM [英] Virtualbox- Cant access to VM when running in Headless mode

查看:88
本文介绍了Virtualbox- 在 Headless 模式下运行时无法访问 VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 virtualbox 上安装了带有 openssh serverubuntu 服务器 并且它工作正常.当我从 GUI 启动它时,我可以通过 ssh 和 Putty 访问它,没有问题.当我从 virtualbox gui 以无头模式启动它时,也没有问题.

I installed an ubuntu server with openssh server on a virtualbox and it works fine. when I start it from GUI I can access it via ssh and Putty, there is no problem. When I start it In headless mode from virtualbox gui there is no problem either.

问题是,当我使用 VBoxManage startvm "Ubuntu" --type headless 运行它时,它返回一条消息,说 Ubuntu 正在以无头模式运行,但是当我想通过 ssh 连接到它,它无法访问.我的主机操作系统是 windows 10,ubuntu 服务器名称是Ubuntu",操作系统版本是 ubuntu-16.04.2-server-x64,我安装了 openssh-server 和 <代码>dkms 如此处所述:https://www.htpcbeginner.com/install-virtualbox-guest-additions-on-ubuntu-debian/

the problem is, when I run it using VBoxManage startvm "Ubuntu" --type headless it returns a message saying that the Ubuntu is running in headless mode but when I want to connect via ssh to it, its not accessable. my host os is windows 10 and the ubuntu server name is "Ubuntu" and os version is ubuntu-16.04.2-server-x64 and I installed openssh-server and dkms as it described here: https://www.htpcbeginner.com/install-virtualbox-guest-additions-on-ubuntu-debian/

当我在 GUI 中工作时,一切都很好,但我想从 Windows 命令行运行它以节省一些时间.

when I work in GUI evrything is fine but I want to run it from windows command line to save some time.

看起来命令行 vm "Ubuntu" 与 GUI vm "Ubuntu" 不同.但是我在virtualbox上只有一个虚拟机.在 gui 中有一个,在 cmd vboxmanage list vms 中返回一个 vm.那么问题是什么?我还在虚拟机 GUI 的设备菜单中添加了虚拟机来宾添加

It looks like that the command line vm "Ubuntu" is diffrent from GUI vm "Ubuntu". But I have only one vm on virtualbox. in gui there is one and in cmd vboxmanage list vms returns one vm. so what is the problem? I also added virtualbox guest addition from Device menu in virtualbox GUI

我看到另一个命令:VBoxHeadless --startvm "Ubuntu" 它也不起作用.但与最后一个命令不同,它不显示 Ubuntu 正在运行的消息.实际上它会卡在执行中,并且光标永远变成闪烁的破折号.所以我应该关闭 cmd 来解决它.

I saw another command : VBoxHeadless --startvm "Ubuntu" its not working either. but unlike the last command it does not show message that Ubuntu is Running. actually it will stuck in execution and the cursor turns to a blinking dash for ever. so I should close the cmd to get ride of it.

我检查了一些东西.如果我在网络适配器和端口转发上使用 NAT,它甚至可以从 cmd 工作.但是当使用网桥避免使用端口转发时,它不起作用.在桥接模式下,有连接并且 ping 工作正常,但无法通过 ssh 连接到 Ubuntu.

I checked something. If I use NAT on network adapter and port forwarding, it works even from cmd. but when using bridge to avoid using port forwarding its not working. in the bridge mode there is connection and ping is working but cant ssh to the Ubuntu.

推荐答案

我找到了解决方案.解决方案是我应该将 NAT 接口保持为默认情况下的主要接口,并在 virtualbox gui 设置中创建一个辅助接口.辅助接口应该是 Host-only.然后通过使用 this 问题及其答案,我将来宾 Ubuntu 的接口添加到静态地址.现在,即使我从命令行运行 vm,我也可以 ssh 到静态 Ip 地址,并且不需要端口转发.

I found the solution. the solution is I should keep the NAT interface as primary as is by default and make a secondary interface in virtualbox gui settings. the secondary interface should be Host-only. then by using this question and its answer I added an interface to guest Ubuntu to a static address. now I can ssh to the static Ip address even if I run the vm from command line, and there is no need to port forwarding.

这篇关于Virtualbox- 在 Headless 模式下运行时无法访问 VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆