如何使用 Emacs TRAMP 双跳 ssh? [英] How can I use Emacs Tramp to double hop ssh?

查看:16
本文介绍了如何使用 Emacs TRAMP 双跳 ssh?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的校园只允许通过网关服务器进行 ssh 访问.因此,要访问我正在编码的集群,我必须通过 ssh 连接到网关,然后通过 ssh 连接到我正在使用的机器.有时连接速度很慢,工作令人沮丧.

My campus only lets ssh access through a gateway server. So to access the cluster I am coding on I have to ssh to the gateway and then ssh to the machine I am working on. The connection is very slow at times and is frustrating to work on.

我很想使用像tramp这样的东西,我知道它会在我的本地机器上打开缓冲区,并且只有在我保存到磁盘时才通过网络进行通话.我对流浪汉一点都不熟悉,并且努力让它工作,尤其是通过双跳.文档说这是通过在 tramp 中定义代理来完成的,但我无法理解语法.

I would love to use something like tramp which I understand would have the buffer open on my local machine and only talk through the network when I save to disk. I am not very familiar with tramp at all and struggling to get it to work, especially through the double hop. The documentation says this is accomplished through defining proxies in tramp, but I am unable to understand the syntax.

有谁知道如何使用 emacs 通过双跳进行编码,或者有通过两个 ssh 跳编辑代码的替代解决方法吗?

Does anyone know how to use emacs to code through a double hop or have an alternate workaround for editing code through two ssh hops?

推荐答案

如果您有 Emacs 24.3 或更高版本,请参阅 Joe 的回答 用于替代下面描述的配置.如果您将多次使用此双跳,可能值得修改 tramp-default-proxies-alist 如下所述,或设置 tramp-save-ad-hoc-代理t.

If you have Emacs 24.3 or later, see Joe's answer for an alternative to the configuration described below. If you'll be using this double hop more than once, it may be worth either modifying tramp-default-proxies-alist as described below, or setting tramp-save-ad-hoc-proxies to t.

如果您有 Emacs 23.1 或更高版本,则不再支持 multi 方法.您可以通过配置代理"来获得相同的结果.

If you have Emacs 23.1 or later, then the multi method is no longer supported. You can achieve the same result by configuring "proxies".

在您的 .emacs 配置文件中添加以下内容:

In your .emacs config file add the following:

(add-to-list 'tramp-default-proxies-alist
                 '("HOSTB" nil "/ssh:USERA@HOSTA:"))

其中 HOSTB 是 HOSTA 后面的目标主机.

Where HOSTB is the destination host behind HOSTA.

然后输入/ssh:USERB@HOSTB:,emacs 会提示输入 HOSTA 密码,然后是 HOSTB 密码.

Then type /ssh:USERB@HOSTB: and emacs will prompt for the HOSTA password then the HOSTB password.

这篇关于如何使用 Emacs TRAMP 双跳 ssh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆