Press "Enter" to skip to content

windows的Linux子系统配置让Windows启动时自动启动

  1. Set up sshd on distro of choice. Ensure it works (firewall set up properly, etc.) when launched manually
  2. Ensure that the distro which will run sshd is the default distro (use wslconfig)
  3. Create a task using Task Scheduler (taskschd.msc) that has the action “Start a program”, with the program set to wsl with optional arguments -u root service ssh start
  4. Set the task to run on computer startup. Specify a user account to run the task as, and specify that the task run whether or not the user is logged in

第一步,你先把你的Linux子系统配置好,ssh安装好,配置好防火墙可以访问。

第二部,确保你的子系统是默认子系统,使用wslconfig /l 看下是不是配置的默认wsl。

第三部,创建一个计划任务,在命令行里面输入 taskschd.msc, 打开计划任务管理面板。操作 -> 创建任务 -> 名称随便填、安全选项:不管用户是否登录都运行、触发器:增加个启动时的触发器、操作:启动程序,程序里面填写wsl,参数输入 -u root service ssh start。

第三部,重启系统,验证下你的配置是否生效。

参考资料:

https://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11#gistcomment-2927883

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注