安装wsl

控制面板->程序->程序和功能->左侧->启用或关闭Windows功能->适用于Linux的Windows子系统
windows应用商店输入ubuntu 下载安装 然后输入账户密码

换源

sudo vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

sudo apt update
sudo apt upgrade

配置远程ssh连接

sudo apt remove openssh-server
sudo apt install openssh-server
sudo vim /etc/ssh/sshd_config

Port 2222                      # 设置ssh的端口号, 由于22在windows中有别的用处, 尽量不修改系统的端口号
PermitRootLogin yes            # 可以root远程登录
PasswordAuthentication yes     # 密码验证登录

:wq
sudo /etc/init.d/ssh restart

原文链接:https://blog.csdn.net/lcuwb/article/details/82885920

root执行权限

sudo nano /etc/sudoers
%sudo ALL=NOPASSWD: /etc/init.d/ssh start

wsl.vbs

Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl sudo /etc/init.d/ssh start", vbhide

开机自启动

开始->运行 shell:startup 将上面的vbs文件放入其中

访问windows磁盘

默认windows磁盘会挂载到 /mnt 可以进行对windows磁盘的操作