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 😅.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

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...

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay