![适用于 Linux 的 Windows 子系统和 SSH 端口转发](https://linux22.com/image/1505462/%E9%80%82%E7%94%A8%E4%BA%8E%20Linux%20%E7%9A%84%20Windows%20%E5%AD%90%E7%B3%BB%E7%BB%9F%E5%92%8C%20SSH%20%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91.png)
是否可以在 Windows Subsystem for Linux 中使用 SSH 端口转发?
如果我下载原生的 OpenSSH 包,我可以转发端口:
> ssh -L 5432:localhost:5432 me@host
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.6.5-x86_64-linode71 x86_64)
etc
但如果我在 WSL bash 中尝试同样的事情:
$ ssh -L 5432:localhost:5432 me@host
bind: Address already in use
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.6.5-x86_64-linode71 x86_64)
etc
我正在以管理员身份运行 bash(并且尝试过不以管理员身份运行)。
答案1
自我回答:参见这个错误。 以下工作:
ssh -L 127.0.0.1:5432:localhost:5432 me@host
问题在于 IPv6 在 WSL 中不起作用,并且故障转移到 IPv4 端口转发。