让wsl的linux子系统支持systemctl实现sshd自启动
WSL Ubuntu是默认无法使用标准的命令来开启sshd开机自启动的,使用标准的ubuntu命令,会报如下错误:
sudo systemctl start sshd
System has not been booted with systemd as init system (PID 1). Can't operate.
编辑wsl ubuntu的wsl.conf文件,如果不存在则创建一个:
sudo vim /etc/wsl.conf
[boot]
systemd=true
关闭windows上的对应wsl子系统然后重启:
wsl --shutdown
再次启动ssh服务成功:
sudo systemctl start sshd