安装完虚拟机之后想在windows下用xshell链接Ubuntu虚拟机
这种配置下,虚拟机能上网,又能跟win连接,感觉很完美
VirtualBox的端口转发很不错,可以转发tomcat什么的
准备工作
1.给Ubuntu安装openssh-server
1 | sudo apt-get install openssh-server |
2.查看虚拟机ip 我的是:10.0.2.15(看上面那段)
1 | hisen@hisen-VirtualBox:/$ ifconfig -a |
VirtualBox设置端口转发
- 在VirtualBox启动页面,右键Ubuntu —>设置
- 网络 —> 连接方式 —> 网络地址转换(NAT)
- 高级 —> 端口转发 —> 点击添加按钮
名称 | 协议 | 主机IP | 主机端口 | 子系统IP | 子系统端口 |
---|---|---|---|---|---|
ssh | TCP | 127.0.0.1 | 2222 | 10.0.2.15 | 22 |
子系统ip写你的虚拟机ip即可
xshell链接Ubuntu虚拟机
在xshell链接Ubuntu虚拟机的时候
ip写上麦的主机ip:127.0.0.1
端口写上面的主机端口:2222
然后上面配置的端口转发就可以转发到虚拟机上,顺利连接!!!