Thursday, February 16, 2012

Configuring Emacs: Remote Editing

TRAMP provides Emacs the ability to remotely edit file over a number of protocols including ssh.

To get a directory listing of the home directory on the remote server:

C-x C-d

You can add the following snippet to also support sudo'ing on the remote box.

(require 'tramp)
(set-default 'tramp-default-proxies-alist (quote ((".*" "\\`root\\'" "/ssh:%h:"))))
Now you can remotely edit the /etc/motd file as root without needing to login as root.  Instead you will login as your user and then sudo to root.

C-x C-f