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

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

问题描述

我的校园只允许通过网关服务器进行ssh访问。所以要访问集群我编码我必须ssh到网关,然后ssh到我正在处理的机器。这个连接有时非常慢,并且令人沮丧的工作。



我喜欢使用类似流行的东西,我明白会在本地机器上打开缓冲区,当我保存到磁盘时,只能通过网络通话。
我不是很熟悉流浪汉,并且努力让它上班,特别是通过双跳。文档说这是通过在tramp中定义代理来实现的,但是我无法理解语法。



有没有人知道如何使用emacs通过双跳或有一个备选的解决方法,通过两个ssh hops编辑代码?

解决方案

如果您有Emacs 24.3或更高版本,请参阅 Joe的答案以替代以下配置。如果你不止一次使用这个双跳,可能需要修改 tramp-default-proxies-alist ,如下所述,或者设置 tramp-save-ad-hoc-proxies to t






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



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

 (add-to-list'tramp-default-proxies-alist 
'(HOSTBnil ssh:USERA @ HOSTA:))

其中HOSTB是HOSTA背后的目标主机。 >

然后键入 / ssh:USERB @ HOSTB:,emacs将提示HOSTA密码,然后HOSTB密码。


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.

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.

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?

解决方案

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.


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".

In your .emacs config file add the following:

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

Where HOSTB is the destination host behind HOSTA.

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

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

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