Linux – Windows Subsystem for Linux & SSH Port Forwarding

bashport-forwardingsshwindows-10-v1607windows-subsystem-for-linux

Is it possible to use SSH port forwarding in Windows Subsystem for Linux?

If I download the native OpenSSH package, I can forward ports:

> ssh -L 5432:localhost:5432 me@host
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.6.5-x86_64-linode71 x86_64)
etc

But if I try the same thing from within 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

I am running bash as administrator (and have tried it not running as administrator as well).

Best Answer

Self answer: See this bug. The following works:

ssh -L 127.0.0.1:5432:localhost:5432 me@host

The problem is that IPv6 doesn't work in WSL and the failure flows through to the IPv4 port forwarding.

Related Question