Changes

Jump to navigation Jump to search
1,350 bytes added ,  10:57, 26 March 2012
no edit summary
Some of the things that TRAMP can do include:
* Editing files on a remote development server over SSH (e.g. <codett>/ssh:remote-user@remote.box:/path/to/my/file</codett>)* Editing files on your local machine as root via sudo (e.g. <codett>/sudo::/etc/some/config/file</codett>)* Editing files on a remote server as root via sudo over an SSH connection from another remote machine that exists within a DMZ (requires a little bit of some configuration, see below)
TRAMP is included with Emacs and described in the manual.
 
== Multiple hops ==
 
To set up multiple hop connections you will need to do a little bit of configuration.
 
As an example, let's assume that you want to edit a file located at <tt>/etc/httpd/conf/httpd.conf</tt> as root on a remote server at dev.example.com. You have a regular user account <tt>chris<tt> on the development sever, but you need to use sudo to gain root access before editing the file.
 
Put the following into your configuration files:
 
;; Guard to ensure that TRAMP is available
(if (locate-library "tramp")
(eval-after-load "tramp"
;; The actual TRAMP configuration
'(add-to-list 'tramp-default-proxies-alist
'("\\`dev\\.example\\.com\\'"
"\\`chris\\'"
"/ssh:%h:"))))
 
After this is evaluated, Emacs knows that the hostname dev.example.com must be accessed over SSH by a user called chris.
 
If you now try to find <tt>/sudo:dev.example.com:/etc/httpd/conf/httpd.conf</tte> Emacs will automatically create the SSH connection first, prompting you for your password if necessary. Then it will prompt you for your sudo password. Once this is all done you will be able to modify the buffer as necessary. Saving the buffer will do what you expect: it will update the file on the remote server.
 
Hops can be chained, making this feature extremely powerful.
40

edits

Navigation menu