背景说明
我的环境清单:
- Win10宿主机
- WSL Ubuntu 20.04 UWP
- Virtual Box 6.1下使用mininet-2.2.2镜像文件创建的虚拟机
起因是按照mininet官网说明执行虚拟机内的wireshark, 这需要在宿主机上运行X server, 开启WSL下SSH的X11 forwarding功能, 并连接到虚拟机, 之后即可正常运行虚拟机内的图形程序
配置步骤
- X server
X server 在Win10下主要有两种开源实现:
Xming和vcxsrv, 前者内置捐赠, 等于变相付费, 后者免费并且使用Windows原生VS C++进行编译, 无脑选2
下载完成后点击开始菜单XLaunch一路默认即可
- 开启客户端和服务端X11 forwarding
X11 forwarding needs to be enabled on both the client side and the server side.
On the client side, the
-X
(capital X) option tossh
enables X11 forwarding, and you can make this the default (for all connections or for a specific conection) withForwardX11 yes
in~/.ssh/config
.On the server side,
X11Forwarding yes
must specified in/etc/ssh/sshd_config
. Note that the default is no forwarding (some distributions turn it on in their default/etc/ssh/sshd_config
), and that the user cannot override this setting.所以主要是设置好WSL的sshd配置文件
- 大功告成, 执行ssh
ssh -X mininet@mininet-vm