Reputation: 2639
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.
Upvotes: 8
Views: 4804
Reputation: 1328712
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
Upvotes: 2
Reputation: 46
To get started, you need to:
Install an OpenSSH compatible SSH client if one is not already present.
Install Visual Studio Code or Visual Studio Code Insiders.
Install the Remote Development extension pack.
Read more : https://code.visualstudio.com/docs/remote/ssh
Installations extension :
code.exe --install-extension ms-vscode-remote.remote-ssh
Follow the step-by-step tutorial or if you have a simple SSH host setup, connect to it as follows:
Press F1 and run the Remote-SSH: Open SSH Host... command. Enter your user and host/IP in the following format in the input box that appears and press enter: user@host-or-ip or user@domain@host-or-ip If prompted, enter your password (but we suggest setting up key based authentication). After you are connected, use File > Open Folder to open a folder on the host.
You can press F1 to bring up the Command Palette and type in Remote-SSH for a full list of available commands. command list
You can change the location by launching VS Code with the --extensions-dir command-line option.
Where are extensions installed?# Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder:
Windows %USERPROFILE%.vscode\extensions
Linux ~/.vscode/extensions
macOS ~/.vscode/extensions
To run remote ssh and open the folder in command-line :
code.exe --remote [email protected] <your-directory>
Upvotes: 1
Reputation: 15018
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.)
Upvotes: 10