Mike Slinn

Opening a Remote Project from the Command Line using Visual Studio Code

Published 2026-11-27.
Time to read: 1 minutes.

This page is part of the posts collection, categorized under Visual Studio Code.

Shell
$ code \
  --new-window \
  --folder-uri "vscode-remote://ssh-remote+mslinn@bear/mnt/f/work/ruby/my_gems/live_source"

I defined an alias called live_source that opens the live_source project on computer Bear:

~/.bash_aliases fragment
alias live_source='code --new-window --folder-uri "vscode-remote://ssh-remote+mslinn@bear/mnt/f/work/ruby/my_gems/live_source"'
alias msp='code --new-window --folder-uri "vscode-remote://ssh-remote+mslinn@bear/var/sitesUbuntu/www.mslinn.com"'

To launch Visual Studio Code and open a remote project folder or file over SSH, pass a vscode-remote:// URI to the code CLI with --folder-uri (or --file-uri):

# Open a remote folder using an SSH config host alias or user@host
code --folder-uri "vscode-remote://ssh-remote+my-server/home/user/projects/my-app"

# Open a specific remote file
code --file-uri "vscode-remote://ssh-remote+my-server/home/user/projects/my-app/README.md"

# Open in a new window instead of reusing the current one
code --new-window --folder-uri "vscode-remote://ssh-remote+user@192.168.1.50/var/www/app"

Common Variations & Tips

  • Host format: Replace my-server with a Host alias defined in ~/.ssh/config or with user@hostname (or user@ip-address). If using a non-default SSH port defined in ~/.ssh/config, the alias automatically picks it up.

  • Percent-encoding special characters: If your host or path contains spaces or special characters (such as @, #, or %), percent-encode them in the URI (for example, %20 for spaces).

  • Prerequisites: The Remote - SSH extension (ms-vscode-remote.remote-ssh) must be installed in VS Code, and the code command must be in your local PATH (on macOS, run Shell Command: Install ‘code’ command in PATH from the Command Palette if needed).

  • From inside an existing SSH shell: You can also SSH into the machine first and run code /path/to/project—VS Code will open a local window connected back to that remote path if SSH forwarding/integration is active, though code --folder-uri "vscode-remote://ssh-remote+..." from your local terminal is the most direct way to launch it on demand.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.