The TRAMP that I am referring to is the Transparent Remote Access Multiple Protocol module for emacs, my favorite editor. Using TRAMP I can edit files remotely from within emacs using either smb, ftp, rsync, sftp, scp, rsh, rcp or ssh as transport protocols.
Now, the ability to edit files remotely is nothing new or revolutionary but TRAMP has some very neat tricks up it’s sleeve. Besides the ability to use ssh to securely connect to remote servers, it also supports the use of su and sudo. Imagine that you would like to edit some file in /etc/ that was owned by root but root login was disabled in your ssh configuration. Logging in using your normal user wouldn’t help you much and you would have to either allow root logins via ssh or log on to the server in question, su to root and then edit the file. Or you could use TRAMP
TRAMP has the ability to use multiple hops to achieve a connection — that means that it’s possible to log on to a server as your normal user and then have TRAMP execute su or sudo on the remote machine for you. It’s actually pretty simple — here is the relevant section from my .emacs file :
;; TRAMP stuff
(require ‘tramp )
(setq tramp-default-method “ssh”)
(add-to-list ‘tramp-default-proxies-alist ‘(“\.myunix\.dk\’” “\‘root\’” “/ssh:%h:”))
(add-to-list ‘tramp-default-proxies-alist ‘(“\.example\.com\’” “\‘root\’” “/ssh:%h:”))
(setq tramp-auto-save-directory “~/.emacs.d/tramp-autosave”)
Now if I try to open the file /su:email@example.com:/etc/hosts emacs would first prompt me for the password for user “example” and upon a successful connection prompt me for the root password of the machine in question. If all goes well then emacs reads the content of /etc/hosts into the buffer.
TRAMP also support the chaining of hosts in the same manner. Very useful for accessing hosts that are only reachable from certain machines, such as gateways or bastion hosts.
Since the remote file resides in a normal emacs buffer you can work on it like any other local file.
I really like the fact that I can edit files securely on remote machines without ever leaving the comfort of trusty old emacs.