The Emacs Tramp package is a wonderful thing. With it, you can easily edit files on remote machines in a virtually transparent fashion. Most Emacs users are familiar with Tramp and use it to edit files on machines on the local network or on remote-network machines directly reachable on the Internet. Often times, though, those remote-network machines are not directly reachable.
A typical example occurs when a developer is working from home and needs to access a machine on his work network that is protected by a firewall. Emacs, of course, can also handle this case. The normal way is to set rules for how to reach remote-network hosts in your .emacs
or init.el
file. The rules are a bit complex but are documented in the Tramp manual. Sometimes, though, you just want a one-off access to some protected host and it’s a pain to temporarily add Tramp configuration rules for it.
Fortunately, David Vázquez has tweeted the answer:
#emacs tramp multi-hops: edit /path in remotehost, using bastion as a proxy.
C-x C-f /ssh:bird@bastion|ssh:you@remotehost:/path
wow!
— David Vázquez (@davazp) August 13, 2014
Unless you need to repeatedly access some remote host, this is a much easier method. The tweet tells you just about everything you need to know but you can see the details in the Tramp documentation.