Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text editor that can edit using sudo over ssh?

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 [email protected]

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

like image 913
db-user Avatar asked Dec 05 '13 23:12

db-user


4 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
like image 40
Andrew Avatar answered Oct 13 '22 10:10

Andrew


For remote editing, there are lots of options here: This answer, like any other, is sure to become outdated as more options enter the field.

  • For vim, the netrw module meets this need, and is shipped with the editor by default.
  • For emacs, this is available with TRAMP.
  • For the ATOM editor, see the remote-files plugin.
  • For IntelliJ, editing files on remote hosts is supported in the commercial edition.
  • For Eclipse, see the Remote System Explorer from the Target Management project.

I'd suggest starting with the editor you prefer and evaluating options from there. If you set up your SSH session to be able to authenticate directly to root (password auth is best disabled for root, but if you have sudo you can install RSA keys), then you'll be able to specify root as a target user for any of the above.


By contrast, if you really do need sudo, you still have options:

  • See Using tramp to open files sudoed to root on the Emacs wiki. New versions also support a ssh+sudo transport, meaning this wiki entry may already be out-of-date.
like image 51
Charles Duffy Avatar answered Oct 13 '22 09:10

Charles Duffy


amazon now acquire Cloud9, which is a browser-based IDE that can edit your EC2.

https://aws.amazon.com/cloud9/

like image 29
the_answer_is_xyz Avatar answered Oct 13 '22 11:10

the_answer_is_xyz


Just modify the appropriate files on your local machine and scp the file into the remote machine.

scp <local_machine_path_to_file> remoteUser@remoteHostName:<filePath>
like image 40
Ryhan Avatar answered Oct 13 '22 10:10

Ryhan