DEV Community

Cover image for VSCode Remote SSH From the Command Line
Sean Boult
Sean Boult

Posted on • Edited on

4

VSCode Remote SSH From the Command Line

The Remote - SSH extension is very useful for allowing you and edit files remotely.

One awesome feature is allowing you connect to a remote host from the terminal.

code --folder-uri vscode-remote://ssh-remote+<FQDN><RemoteDirectory>
Enter fullscreen mode Exit fullscreen mode

This allows you to create a simple alias to launch VSCode to connect directly to that host.

alias devhost="code --folder-uri vscode-remote://ssh-remote+my.example.com/home/example"
Enter fullscreen mode Exit fullscreen mode

One drawback is you can't currently use hosts from your .ssh/config as of now but I've raised a ~~ feature request ~~for that.

Update: you can use aliases from your .ssh/config, either it was bugged or fixed 😅.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (2)

Collapse
 
ridaehamdani profile image
Ridae HAMDANI

Thanks @hacksore for the tip, specially the alias trick. I used the remote ssh extension only once, I was not very satisfied with it, as it install , I think sort of agent, in the server side. The server was for a production environment and I was not allowed to installed any untrusted tools on it. I do not know if there is an other extension which used a pure ssh

Collapse
 
hacksore profile image
Sean Boult • Edited

Yeah trying to use this to remote into production servers is not always going to fly for the main concern that remote ssh uses a binary downloaded from the internet.

First option would be work with security teams and host the VSCode Server binary internally for Remote SSH and create a script install the binary to the server.

Here is some good reference material for that.
github.com/microsoft/vscode-remote...
github.com/microsoft/vscode-remote...
stackoverflow.com/a/56781109/7578127

Otherwise If that wont work out you're better off using an SFTP client to keep the remote directory in sync with your local.

Mac - docs.cyberduck.io/cyberduck/sync
Windows - winscp.net/eng/docs/task_synchroni...

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more