1.安装 SSH 服务(WSL 内)
sudo apt update
sudo apt install openssh-server -y
2.启动 SSH 服务
# 启动
sudo service ssh start
# 检查状态,active (running) 表示运行中
sudo service ssh status
3.设置允许登录
找到以下两个配置
# 编辑配置
sudo nano /etc/ssh/sshd_config
# 允许密码登录
PasswordAuthentication yes
# 允许 root 账号登录
PermitRootLogin yes
保存:
ctrl + o,然后 ctrl + x
重启服务:
sudo service ssh restart
4.工具连接
不要用物理 IP 地址,比如什么 192.168.67.10,要用 127.0.0.1