How to edit remote files using Remote VSCode

Visual Studio Code is a great editor for local files. Remote VSCode is an extension that enables editing files on remote systems in your local VSCode. Note that you will need to specify individual files on the remote computer and they will appear in your local VSCode. You cannot open a remote folder and expect all of the code there to be indexed for code browsing with this method.

  • Install rmate on the remote computer. rmate has been ported from its original Ruby implementation to Python, Bash and other languages. I like to use rmate-python. Installing it is easy:
$ sudo pip3 install rmate
  • On your local VSCode, install the Remote VSCode extension from here.

  • Open Preferences β†’ Settings and in the User Settings window, add the following settings:

//-------- Remote VSCode configuration --------

// Port number to use for connection.
"remote.port": 52698,

// Launch the server on start up.
"remote.onstartup": true

// Address to listen on.
"remote.host": "127.0.0.1"

// If set to true, error for remote.port already in use won't be shown anymore.
"remote.dontShowPortAlreadyInUseError": false
  • Restart VSCode and run the command Remote: Start server by pressing F1.

  • SSH to your remote machine with port tunneling:

$ ssh -R 52698:127.0.0.1:52698 yourlogin@remotecomputer
  • Once you are SSHed into the remote computer, run this command there:
$ rmate -p 52698 file/you/want/to/edit

The file will appear in your local VSCode for editing. The remote file will be updated with any changes you make locally after you save the file.

Tried with: Visual Studio Code 1.22.2 and Remote VSCode 1.1.0

Advertisements

One thought on “How to edit remote files using Remote VSCode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.