使用SecueCRT连接Linux子系统

1、安装ssh

1
sudo apt-get install openssh-server

设置ssh配置文件

1
2
3
4
5
6
7
8
9
#备份
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
#修改
sudo vi /etc/ssh/sshd_config
#确保以下内容
ListenAddress 0.0.0.0 #监听IP,0.0.0.0表示任意IP均可连接
Port 22 #连接端口
PassWordAuthentication yes #允许使用账号密码登录
PermitRootLogin yes #允许使用root用户登录

2、启动ssh

1
2
3
4
5
6
7
8
9
10
#生成ssh服务的key
dpkg-reconfigure openssh-server
#关闭ssh
service ssh stop
#启动ssh
service ssh start
#重启ssh
sudo service ssh restart
#查看ssh服务
service ssh status

3、配置ssh服务开机启动
Windows键+R键,运行输入 shell:startup
在打开的文件夹内新建wsl.vbs
配置wsl.vbs文件

1
2
Set ws = CreateObject("Wscript.Shell")
ws.run "wsl -d Ubuntu-22.04 -u root /etc/init.d/ssh start", vbhide

4、使用SecueCRT连接Linux子系统
Alt键+Q键,选择SSH2
输入Hostname:127.0.0.1
输入Port:第一步中设置的端口,默认为22