gkeenley
gkeenley

Reputation: 7378

Is it possible to edit code on my own machine and save it to account I've ssh'd into?

Scenario:

I'm using ssh to connect to a remote machine. I use the command line and run ssh <pathname>, which connects me to the machine at . I want to edit and run code on that remote machine. So far the only way I know is to create, edit, and run the files in the command window in vi, because my only connection to that machine is that command window.

My Question is:

I'd love to be able to edit my code in VSCode on my own machine, and then use the command line to save that file to the remote machine. Does anyone know if this is possible? I'm using OS X and ssh'ing into a Linux Fedora machine.

Thanks!

Upvotes: 0

Views: 164

Answers (2)

evil otto
evil otto

Reputation: 10582

You could export the directory on the remote machine using nfs or samba and mount it as a share on your local machine and then edit the files locally.

If you're happy using vim, check out netrw (it comes with most vim distributions; :help netrw for details) to let you use macvim locally to edit the remote files.

Upvotes: 0

Coby Z
Coby Z

Reputation: 63

Sounds like you're looking for a command like scp. SCP stands for secure copy protocol, and it builds on top of SSH to copy files from one machine to another. So to upload your code to your server, all you'd have to do is do

scp path/to/source.file username@host:path/to/destination.file

EDIT: As @Pam Stums mentioned in a comment below the question, rsync is also a valid solution, and is definitely less tedious if you would like to automatically sync client and server directories.

Upvotes: 2

Related Questions