I am using WSL on windows 10 to program, and recently discovered that VS code can be used to edit programs through SSH.
However, I normally SSH into my university's computers through WSL so i can access the files on those systems and use their GPUs.
Is there any way to SSH into WSL using vscode, and then ssh into my universities systems, and have access to their resources and filesystems from with within vscode?
The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.
Visual Studio's WSL 2 toolset allows you to use Visual Studio to build and debug C++ code on WSL 2 distros without adding a SSH connection. You can already build and debug C++ code on WSL 1 distros using the native WSL 1 toolset introduced in Visual Studio 2019 version 16.1.
You can create ssh.bat
file under windows with the content:
C:\Windows\system32\wsl.exe ssh %*
And than set VS Code setting "remote.SSH.path" to point to that bat file.
You’ll have the same ssh configuration and credentials in VS Code as you have in WSL.
If writing C:\Windows\system32\wsl.exe ssh %*
in an ssh.bat
file mostly works but gives you issues where your ~/.bashrc
is not sourced, replace the command with
C:\Windows\system32\wsl.exe bash -ic 'ssh %*'
This tweak runs the ssh
command in an interactive bash shell, which sources your ~/.bashrc
. Using the above fixed an issue I had with the Ubuntu ssh-agent
not forwarding keys on VSCode remote terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With