Text editor that can edit using sudo over ssh?

Viewed 33060

I'm trying to edit files on a remote Amazon EC2 Linux instance. I'm currently just sshing in and using nano, but would really like a graphical text editor. I have two problems:

  1. I have to use sudo to edit these server files when I ssh in.
  2. I can only login with the key Amazon gave me. Ex: ssh -i Andrew.pem ec2-user@55.55.44.33

Please help! I'm not picky, just any graphical text editor since using nano is a huge pain.

12 Answers

To help anyone that just need a quick command line text editor:

you can use vi:

vi file-name.txt

or nano:

nano file-name.txt

optionally use sudo if editing the file, eg:

sudo nano file-name.txt

would really like a graphical text editor

You cannot have a graphic editor, you need to use any editors like nano as you said or vim,emacs. Sudo would be required when you have to edit configuration files with root as owner.

I found a weird workaround for a GUI based text editor on AWS, I used Jupyter Notebook. If you have Anaconda installed on you instance, you follow the following steps

  • ssh onto your instance using ssh -i <location of your private key> <username>@<public DNS>
  • Start jupyter notebook on your instance using jupyter notebook --no-browser --port=8888
  • Open a new terminal window and ssh onto your jupyter notebook using ssh -i <location of your private key> -L 8212:localhost:8888 <username>@<public DNS>
  • Now you can open jupyter notebook at localhost:8212

Using the jupyter notebook environment, you can not only launch and run Ipython notebooks but also create and edit any files like a text editor.

To assist others with this same question, I would suggest jEdit. It is very capable, and it has a very rich plugin environment, language parsing, etc.

http://www.jedit.org

It has "always" supported sftp read and write of files with the sshConsole plugin.

I use it now on my AWS EC2 instance with the key pair supplied by AWS.

Lastly, it is not a good idea to edit files owned by root in the "production" environment.

Do your dev work in the AWS user's home folder so that you have full control of the source files. Then use a symlink to the actual server's file tree so you can serve it to yourself for testing. There are lots of controls in nginx and apache to limit who can view your dev site.

EDIT/UPDATE:

The NppFtp plugin to Notepad++ profides sftp access to AWS. I just tested it with the .pem file that they provided for my login at AWS.

Related