How do you edit files over SSH?

Viewed 114579

I program with eclipse and sometimes use GUI text editors like SciTE or vim. However, I'm at a point in a project that requires me to edit files over a ssh connection in a 80 column SSH window.

Since I have to (* shiver*) sudo vim before I can open the file I'm not sure how to open the file in an editor outside the terminal (that would allow me to see the text wider than 80 columns). If the command line was larger then I guess using straight vim wouldn't be a problem.

I'm at a loss of how to deal with this situation and how I could turn this nightmare into a manageable coding environment.

17 Answers

FileZilla did the trick for me. Notepad++ can be used with it which is awesome.

If you are more GUI-oriented and use one of the more newbie-friendly Linux distros like Ubuntu or Mint, this is another option and does not require any more installations.

You should have nemo as your default file manager. It may not be called "Nemo" on the menu, so go under Help > About of your file manager ("Files" app) to see.

In nemo, go to File > Connect to server, enter your remote machine's details (SSH's default port is 22), and then open the files just like any file on your local machine, with whatever editor you prefer. You can even close Nemo and continue working in your editor.

From the address bar, it seems to be using the sftp protcol.

Just be aware that if your remote host has an inactivity timeout for the SSH connection, this will also prevent you from saving changes in the editor after the timeout has dropped the connection...

Since sshfs is not supported in WSL at the moment, the tool that worked for me is sshfs-win.

Installation Steps

  1. Go here and click "download winfsp"
  2. Install it
  3. Go here and download the installer
  4. Install it
  5. Open windows explorer and right-click "This PC" > "Map Network Drive..."
  6. Select a drive letter (B:), type in "\\sshfs\debian@10.13.100.36" and click Finish
  7. Boom, done. Now you can have a B: drive on your computer and just do whatever with those files. Open them with VSCode, delete them, whatever you like

If you work in IntelliJ IDEA, you can use Friendly Terminal plugin instead of the native terminal. It allows to open and edit remote files in IntelliJ IDEA editor. Video

Related