开发者

Reaching a remote host through a gateway using Emacs and Tramp

开发者 https://www.devze.com 2023-03-10 16:09 出处:网络
I am attempting to edit a remote file in Emacs, and开发者_运维百科 I\'m having trouble getting from the documentation and previous SO questions to doing the thing I want.

I am attempting to edit a remote file in Emacs, and开发者_运维百科 I'm having trouble getting from the documentation and previous SO questions to doing the thing I want.

I'm working remotely, from a variety of locations, and I want to edit files on server Foo. Server Foo isn't directly reachable from the Internet, but server Bar is, and Foo accepts connections from Bar. I can count on reaching Bar, and Bar can count on reaching Foo.

The Tramp documentation tells me that I need to add to Tramp's proxy list to do this, and that it should look like the following:

(add-to-list 'tramp-default-proxies-alist
    ("foo_host" "seanm" "/ssh:seanm@bar_host"))

However, when I try that, it doesn't work, and I get inscrutable error messages.

  • How can I unambiguously refer to Foo? There is no DNS server that knows how to find Foo from its hostname, and Foo's IP address is in the 10.0.0.0/8 private space. I don't want to refer to Foo by that IP address, because that risks colliding with hosts in other 10.0.0.0/8 networks I may visit. As a kludge, I added Foo to Bar's /etc/hosts file, but that didn't seem to work. Is there a better solution?

  • What quoting rules do I need to adhere to? The examples that I'm seeing use both "double quotes" and `tick-and-single' quotes, the latter apparently requiring double-backslash escaping. I don't understand what's going on there - it seems like there are multiple layers of parsing that this string is going to be shoved through.

  • While trying variations on this, I've gotten error messages that amount to "you can't use that remote-access method for that scenario." How can I set up a second proxy method that will let me do the equivalent of C-x C-f /su::/path/to/file ?

It all seems very painful compared to the previous multi-hop syntax.

Later: I was able to get the many layers of escaping right so that emacs correctly 'hears' the names of hosts. However, I can't get any hops beyond a second to work correctly, which is a very disappointing lapse in functionality.


The correct answer turned out to be modifying my SSH config with Host, HostAlias, and ProxyCommand directives.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号