Hi TRIM,
The cleanest way to handle this in VSCode is to configure a chained SSH setup using the ProxyJump directive in your SSH config file. On your Windows workstation, edit %USERPROFILE%\.ssh\config and add an entry for VM2 that specifies VM1 as the jump host. For example:
Host vm1
HostName <VM1_IP>
User <username>
IdentityFile <path_to_key>
Host vm2
HostName <VM2_IP>
User <username>
ProxyJump vm1
IdentityFile <path_to_key>
Once this is in place, VSCode Remote-SSH can connect directly to vm2 by name, and it will automatically tunnel through VM1 without you needing to manually hop terminals. This approach is supported natively by OpenSSH and avoids repetitive manual jumps. If you’re using VSCode’s Remote-SSH extension, make sure it points to the same config file, and restart VSCode after saving changes. This way you can switch between VM1 and VM2 seamlessly in the VSCode explorer without breaking your workflow.
I hope this information clarifies your question. If it does, please mark the answer as accepted or give it a thumbs up to let me know. Wishing you a great day ahead.
Harry.