SSH port forwarding in vscode (Visual Studio Code)
VSCode remote debugging
It’s really great feature - you can have your code on remote server, use git repo on remote server, run debug on remote server and so on, having only window of IDE on your local computer.
First steps to configure vscode for remote development on Windows:
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
https://code.visualstudio.com/blogs/2019/07/25/remote-ssh
Port forwarding
If you run Java, Python, NodeJS, GoLang or whatever on remote Linux server, in many cases it is the server which you’re trying to develop. And if for some reason you server expose some TCP port which is not available from external network (while you have exposed SSH for connection), you need to see this port forwarded to your local computer.
See short description how this can be done within the same SSH connection which you use to connect to console or file system (via SCP or SFTP):
https://www.ssh.com/ssh/tunneling/example
BTW, you can connect to remote PostgreSQL, MySQL, MongoDB or Redis like they all are installed on your local computer. The killer feature…
Ususal errors in vscode
If you’ll setup your connection string as
ssh -A -L 8080:localhost:8080 user@myserver.address.com
you’ll get error like The process tried to write to a nonexistent pipe ...
Search over internet doesn’t give you useful answers.
Solution
After configuring connection string as
ssh -A -L 8080:localhost:8080 user@myserver.address.com
open yous ssh config file (usually C:\Users\%UserName%\.ssh\config
for local user’s configuration) and change the string
LocalForward 8080:localhost:8080
to
LocalForward localhost:8080 localhost:8080
That’s it!
Thanks black_sheep for an answer