80

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.

Xeoncross
  • 55,620
  • 80
  • 262
  • 364
  • I don't actually quite get your question. Do you want to edit the files in a terminal (through an ssh connection)? – William Niu Aug 04 '10 at 15:52
  • I don't actually get my question. I did the best to explain the problem and I'm hoping that someone can provide the answer. Basically, I need to edit files that are only available over SSH - and editing them inside the terminal just isn't cutting it. I want to edit them in a proper GUI editor - but still use the connection over SSH for saving/opening. – Xeoncross Aug 04 '10 at 15:54
  • 3
    Some of your answers ("that would allow me to see the text wider than 80 columns", "allowed me to use it's awesome terminal which allows resizing") make me wonder: Are you SSH-ing inside the Windows command prompt-thing? (ew!) I must recommend something better, for when you are trapped in a Windows environment: "PuTTY": http://www.chiark.greenend.org.uk/~sgtatham/putty/ – Thanatos Aug 05 '10 at 03:38

18 Answers18

113

Maybe you should simply mount the remote filesystem to your local machine and then use whatever editor you like. If running a Debian derivative, install sshfs

sudo apt-get install sshfs

and then mount the remote filesystem ( issue on your local machine )

mkdir ~/remote_code
sshfs $USER@remote.example.com:/home/$USER/code ~/remote_code

Once this is done you can access the code in ~/remote_code w/ any of your GUI tools and without the bandwidth overhead of using ssh -X (however you still need a good connection w/ a low ping time).

PS: When using ssh I can make the terminal as wide as it fits my screen and then use its full width, so I fear I don't completely understand your issue.

xhudik
  • 2,414
  • 1
  • 21
  • 39
  • 1
    I am using windows which is terrible at all things useful (minus Adobe) and switching over to an Ubuntu VM allowed me to use it's awesome terminal which allows resizing! So for now I'll just edit files with vim since I can now make that nasty line-wrapping go away. I will also look into mounting the filesystem! – Xeoncross Aug 04 '10 at 16:02
  • 1
    Glad to hear you already have a workaround for your problem. When using a VM w/ Ubuntu, sshfs should work just as you desire. If you'd like to stick w/ Windows, you could install the tools provided by Cygwin (http://www.cygwin.com/) offering a more capable terminal + shell w/ a nice ssh client etc. – Gerald Senarclens de Grancy Aug 04 '10 at 16:08
  • Just finished setting up sshfs and I'm very pleased with it. Tried looking into fuse but I couldn't figure it out. – Xeoncross Aug 04 '10 at 16:15
29

WinSCP is a SSH client ftp-like. The default editor is primitive but can be change.

Community
  • 1
  • 1
h3xStream
  • 6,293
  • 2
  • 47
  • 57
  • 1
    Yes, I use this with SciTE often. – Xeoncross Aug 05 '10 at 15:36
  • 2
    You can set Notepad++ as the default editor by going Options -> Preferences -> Editors -> Add (point to your N++ install). Then click the Up button until Notepadd++ is at the top of the list. – KERR Mar 15 '18 at 23:18
10

There are various options.

You can make the terminal larger. ;)

If you have a graphical environment installed on the machine you are ssh'ing into, you can login with ssh -X (or xdeep-putty if you are on Windows) to enable window forwarding. You can then run your favourite editor on the remote machine, whose graphical output is forwarded.

Finally, you can mount the ssh connection into your file system, using for example fuse (similar options might exist for non-linux operating systems). That allows you to access any file on the remote machine as if it were in your filesystem, with your favourite editor, locally.

relet
  • 6,819
  • 2
  • 33
  • 41
6

I'm not 100% sure if this works for files owned by root, but if your desktop is KDE & your remote system is Linux (or pretty much any form of *nix), you can get konqueror to access the remote machine using the "fish://" protocol. From there you can open the file from konqueror using kate, or your preferred editor, and konqueror will take care of copying the file to your local machine and copying it back when you save.

Failing which the X11 forward is a good option, but X11 over ssh to remote sites can be slow. "ssh -X -C" compresses the data stream and can give better performance.

  • 1
    You can do this from the KDE *Open File* dialogue (e.g. in Kate) by pressing `Ctrl-L` and typing `fish://user@host:path-to-directory`. – z0r Jun 02 '14 at 00:33
4

Notepad ++ has a plugin for editing files remotely over ssh. I've used it before, but I definitely prefer Kate on KDE using the fish protocol.

http://www.inmotionhosting.com/support/website/ftp-client-setup/connect-ftp-notepad-plus

NuclearPeon
  • 5,743
  • 4
  • 44
  • 52
  • but will it work with SCP instead of FTP? FTP is mostly obsolete because it divulges your passwords in the clear... – Ted Shaneyfelt Mar 16 '21 at 03:31
  • It supports SCP, not just FTP, and it can use private keys provided that you point to the private key file. It won't recognize the .ssh/config settings, though so you have to enter your user name and on a separate tab enable the private key file. – Ted Shaneyfelt Mar 16 '21 at 04:03
3

If you're on Ubuntu, go to Nautilus (file explorer), connect to server (adding sftp:// to the hostname), then voila! You can easily launch gedit to edit your files now.

Cardin
  • 5,148
  • 5
  • 36
  • 37
3

On Windows, you can use MobaXterm ( http://mobaxterm.mobatek.net ): it has a built-in SSH client with a very useful "SFTP browser".

As soon as you connect to your remote server using SSH, you will see your remote files displayed in this graphical SFTP browser. Just double-click on your files and you will be able to edit them directly on your remote server through SFTP.

Didier
  • 600
  • 7
  • 7
3

Forward your X11 session to your terminal.

http://dragonwall.net/xdeep-putty.html

This probably belongs on superuser.com.

Vitor Py
  • 5,145
  • 4
  • 39
  • 62
3

You might try the Komodo editor. It has a feature to load a 'remote file' over ssh. It's really convenient.

JAL
  • 21,295
  • 1
  • 48
  • 66
3

Emacs and ange-ftp.

Patrick
  • 261
  • 3
  • 16
2

I use Cyberduck and Sublime Text 2

egiray
  • 1,169
  • 1
  • 12
  • 17
2

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

VSh
  • 438
  • 4
  • 13
1

If you using windows, try Editplus. It's not free but allows you to open files directly over scp. Custom syntax files are coming really handy, too.

dsomnus
  • 1,391
  • 14
  • 21
1

Recent versions of ultraedit do exactly what the OP is asking for elegantly (IDM software, v10 and up support SSH iirc). I do most of my coding remotely like that, been using it for years, works great with no intermediate files etc. Obviously it also does FTP etc too if you're so inclined.

I actually found this page whilst looking for a linux equivalent of ultraedit..

1

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

frIT
  • 3,213
  • 1
  • 18
  • 22
1

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
nullromo
  • 2,165
  • 2
  • 18
  • 39
0

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

Sergey
  • 841
  • 6
  • 7
0

i wrote a simple shell script to do so get it form https://github.com/KTBsomen/sshedit.git

basically it copy the whole file structure in your local mechine with current date so version controll and backup is automagically done and then runs a watcher for file changes as you change your files it will updated on the server realtime steps to run

sudo ./sshedit.sh

it will install some programm if not found,

then it will ask for host of the ssh connection in a GUI window like 3.23.253.5,

then it will ask for the hostname like ubuntu,

then it will ask for the .pem file it will open a file chooser to select ,

then it will ask for the file path to connect to like /home/ubuntu/,

then it will ask for short code of your code editor like code (for vs code) subl (for sublime text)

change the code as your need and add a pull request

Somen Das
  • 366
  • 2
  • 7