Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vscode (code.exe) command line arguments to immediately open a remote workspace folder over SSH

If I want to open a workspace on a regular local folder under C:\ I can just execute the command:

code.exe C:\the-local-workspace-folder

Is there any equivalent command for opening remote SSH workspaces?

I want to be able to use my keyboard launcher to open them, rather than needing to open them the fiddly way in the internal menus inside vscode.

So I need a regular system command to be able to do this.

I've looked through the command line arguments here: https://code.visualstudio.com/docs/editor/command-line - but can't find anything about remote workspaces at all.

I've also tried commands like:

code.exe [email protected]:/workspace-folder
code.exe [email protected]/workspace-folder

...but they don't work for this.

like image 650
LaVache Avatar asked Jun 17 '26 01:06

LaVache


2 Answers

This looks like a recent fix, according to the issue tracking here. I've tested with my own settings, and this works:

"C:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\Code.exe" \
    --remote ssh-remote+myubuntumachine /home/myusername/myprojectdirectory

The myubuntumachine should be the name given in the Host myubuntumachine in the SSH config file on CTRL+SHIFT+P/Remote SSH: Open Configuration File...

(Actually, on my machine I don't have the machine name, but some sort of hash value, although either works.)

like image 133
Ken Y-N Avatar answered Jun 19 '26 18:06

Ken Y-N


VSCode 1.63 (Nov. 2021) adds the option -n (issue 137529), to make sure a new window is opened for remote CLI:

The following options got added to the remote CLI:

-n to open a new window of the same remote as the current window -n --remote=wsl+ubuntu to open a new window of a different remote -n --remote=local to open a new local window

like image 22
VonC Avatar answered Jun 19 '26 17:06

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!