gpt4 book ai didi

Emacs TRAMP ssh 双跳

转载 作者:行者123 更新时间:2023-12-04 16:36:31 24 4
gpt4 key购买 nike

有人可以帮我设置 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:"))

这是我对手册内容的最佳猜测解释。然后我这样做:
C-x C-f/ssh:machine2.abc.def.edu
或者:
C-x C-f/ssh:rsuhada@machine2.abc.def.edu

但两者都给出:
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:myname@machine1.abc.def.edu:"))

具有相同的结果......也适用于我能想到的所有组合......不过,machine1.abc.def.edu 上的远程编辑工作正常。

最佳答案

答案它使用ssh_proxy ssh_config 中可用的命令。记录 herehere .基本上,您可以在 ssh 文件夹中创建一个配置文件,您可以在其中写入快捷方式。其中一个快捷方式是通过另一个端点使用代理。您的所有快捷方式都适用于任何使用 ssh 的工具,包括 git 和 emacs。

Host endpoint2
User myusername
HostName mysite.com
Port 3000
ProxyCommand ssh endpoint1 nc -w300 %h %p

Host endpoint1
User somename
HostName otherdomainorip.com
Port 6893

在这个例子中运行 ssh endpoint2将自动跳过端点 1。

关于Emacs TRAMP ssh 双跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5847814/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com