DEV Community

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

Posted on • Updated on

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

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