`

ssh连接virtualbox中虚拟主机

    博客分类:
  • java
阅读更多

ssh连接virtualbox中虚拟主机

virtualbox中虚拟主机默认安装完成后联网模式默认为NAT,宿主机及外部网络不能直接访问客户机,因此需要为客户机建立端口映射。
建立端口映射的命令格式为:

VBoxManage setextradata 虚拟主机名称 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/服务名称/Protocol" TCP
VBoxManage setextradata 虚拟主机名称  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/服务名称/HostPort"  映射后的端口 
//这个端口可以自由设定
VBoxManage setextradata 虚拟主机名称  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/服务名称/GuestPort" 现在服务端口

关闭客户机,在宿主机VirtualBox程序文件夹中建立一个批处理文件,编辑命令如下:
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" TCP
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" 80
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" 80

VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssl/Protocol" TCP
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssl/GuestPort" 443
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssl/HostPort" 443

VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/mysql/Protocol" TCP
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/mysql/GuestPort" 3306
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/mysql/HostPort" 3306

VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata 客户机名 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
注:上面是开启了80 mysql ssl ssh服务。
如果在cmd中执行命令 首页要把目录cd为VBoxManage命令所在目录。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics