场景:需要本地Windows Native开发,也需要WSL开发,还需要Remote SSH开发。
目前Codex APP的设置里可以手动选择Agent 为 wsl 还是 Native,不知道是哪个脑袋想出来的方案。
既然目前支持remote ssh了。那么直接ssh登录wsl即可。
- wsl 支持 ssh
sudo apt update
sudo apt install -y openssh-server bubblewrap
sudo systemctl enable ssh
sudo systemctl start ssh
sudo nano /etc/ssh/sshd_config
配置如下,避开22端口
Port 2222
PubkeyAuthentication yes
PasswordAuthentication no
sudo systemctl restart ssh
- win11 配置
C:\Users<YourWindowsUser>.ssh\config
Host wsl-ubuntu
HostName localhost
Port 2222
User <你的WSL用户名>
IdentityFile C:\Users\YourName\.ssh\id_ed25519
增加ssh key到wsl
type $env:USERPROFILE\.ssh\id_ed25519.pub | wsl sh -c "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"
ssh 命令验证能否登录
ssh wsl-ubuntu
- Codex APP 配置
按照remote ssh正常操作即可。
1 个帖子 - 1 位参与者