Emacs Tramp ssh 双跳
有人可以帮我设置 Emacs Tramp 来进行双跳吗? 我想在 machine2.abc.def.edu 上工作,我只能通过 machine1.abc.def.edu 连接到它。我的用户名是 myname,两台机器上的用户名相同。
我尝试添加 .emacs:
(add-to-list 'tramp-default-proxies-alist
'("\\`machine2\\.abc\\.def\\.edu\\'"
"\\`myname\\'"
"/ssh:machine1\\.abc\\.def\\.edu:"))
这是我对手册内容的最佳猜测解释。然后我这样做: Cx Cf /ssh:machine2.abc.def.edu 或者: Cx Cf /ssh:[email protected]
但两者都给出:
ssh: Could not resolve hostname ssh: nodename nor servname provided, or not known
Process *tramp/scpc ssh* exited abnormally with code 255
和我的 Aquamacs无法退出,必须从 shell 中杀死...这里有一个 2 年的线程有同样的问题。我已经尝试了那里的答案:
(add-to-list 'tramp-default-proxies-alist
'("machine2.abc.def.edu"
nil
"/ssh:[email protected]:"))
具有相同的结果...也适用于我能想到的所有组合...不过,在 machine1.abc.def.edu 上进行远程编辑效果很好。
Could somebody please help me setup Emacs Tramp to do a double hop?
I want to work on machine2.abc.def.edu to which I can connect only through machine1.abc.def.edu. My username is myname, on both machines same.
I've tried to add .emacs:
(add-to-list 'tramp-default-proxies-alist
'("\\`machine2\\.abc\\.def\\.edu\\'"
"\\`myname\\'"
"/ssh:machine1\\.abc\\.def\\.edu:"))
This is my best guess interpretation of what's in the manual. Then I do:
C-x C-f /ssh:machine2.abc.def.edu
or:
C-x C-f /ssh:[email protected]
But both give:
ssh: Could not resolve hostname ssh: nodename nor servname provided, or not known
Process *tramp/scpc ssh* exited abnormally with code 255
And my Aquamacs can't be quitted and have to killed from shell... There is a 2 years thread here with same question. I've tried the answer from there:
(add-to-list 'tramp-default-proxies-alist
'("machine2.abc.def.edu"
nil
"/ssh:[email protected]:"))
With same results... also for all combinations I could come up with... Remote editing on machine1.abc.def.edu works fine, though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,让我们尝试一些不同的东西,而不是打开隧道。您的 .emacs 文件中的以下内容怎么样:
这与您在论坛帖子中找到的代码有两点不同:
名称(要避免的 Emacs 正则表达式语法
匹配部分名称)
目标中的子域名
主持人(您在评论中报告
下面你不能 ssh 到
machine2 当您使用完整的
域名)
当您尝试访问 machine2 上的文件时这有帮助吗?
Okay, let's try something different then, without opening a tunnel. How about the following in your .emacs file:
This is different from the code you found in the forum post in two points:
name (Emacs regexp syntax to avoid
matching partial names)
the subdomain name in the target
host (you reported in a comment
below that you cannot ssh to
machine2 when you use the full
domain name)
Does that help when you try to access a file on machine2?
设置从 machine1 到 machine2 的 ssh 隧道(假设 sshd 在 machine2 上的端口 22 上运行):
然后从 Emacs 连接到 machine2,如下所示:
或将以下行添加到您的 .emacs:
Set up an ssh tunnel from machine1 to machine2 (assuming that sshd runs on port 22 on machine2):
Then either connect to machine2 from Emacs like this:
or add the following line to your .emacs:
答案是使用 ssh_config 中提供的 ssh_proxy 命令。记录在此处和此处。基本上,您在 ssh 文件夹中创建一个配置文件,您可以在其中写入快捷方式。快捷方式之一是通过另一个端点使用代理。所有快捷方式都适用于任何使用 ssh 的工具,包括 git 和 emacs。
在此示例中,运行
ssh端点2
将自动跳转到端点1。The answer it to use the ssh_proxy command available in ssh_config. Documented here and here. Basically you create a config file in your ssh folder that you can write shortcuts in. One of your shortcuts is to use a proxy through another end point. All of your shortcuts work for any tool that uses ssh including git and emacs.
In this example running
ssh endpoint2
will automatically hop through endpoint1.