简体   繁体   English

Emacs + tramp + plink

[英]Emacs + tramp + plink

I'm trying to get emacs tramp running under Windows XP to work over putty plink on an Amazon EC2 instance. 我试图在Windows XP下运行emacs tramp来处理Amazon EC2实例上的putty plink。 The documentation for doing this is sparse. 这样做的文档很少。 I can find partial documentation, but none that addresses all the steps required to get this working. 我可以找到部分文档,但没有一个可以解决使其工作所需的所有步骤。

Can anyone provide a walk through, or a pointer to a walk through? 任何人都可以提供一个漫步,或指向步行通过?

(add-to-list 'load-path
 (expand-file-name "C:/tools/emacsw32/emacs/lisp/tramp/lisp"))
(require 'tramp)
;(setq tramp-chunksize "500")
(setq tramp-default-method "plink")

from my dot-emacs file. 来自我的dot-emacs文件。 If I find more notes, I shall add them here. 如果我找到更多笔记,我会在这里添加。

I'll assume you have a GNU/Linux server you want to access, a username and a .ppk file. 我假设你有一个想要访问的GNU / Linux服务器,一个用户名和一个.ppk文件。 Also, Emacs 24.4+. 此外,Emacs 24.4+。

First set up server in PuTTY Configuration 首先在PuTTY Configuration中设置服务器

  1. In section Session, specify Host Name, for example username@server . 在Session部分中,指定Host Name,例如username@server
  2. Go to section Connection > SSH > Auth and Browse for your "Private key file for authentication". 转至“连接”>“SSH”>“身份验证”部分,然后浏览“用于身份验证的私钥文件”。
  3. Back to section Session, name your Saved Sessions, for example putty-test , and click Save button. 返回“会话”部分,为“已保存的会话”命名,例如putty-test ,然后单击“保存”按钮。
  4. Check your connection by clicking the Open button. 单击“打开”按钮检查连接。 If it works, you can close these now. 如果有效,您可以立即关闭它们。

Next, head to your Emacs. 接下来,前往您的Emacs。

  1. Make sure Emacs knows where your plink.exe is. 确保Emacs知道你的plink.exe在哪里。 One way is to just inform Emacs directly in your .emacs , for instance I have at the moment, (setenv "PATH" (concat "c:/Users/Brady/Documents/putty/;" (getenv "PATH"))) 一种方法是直接在您的.emacs通知Emacs,例如我目前, (setenv "PATH" (concat "c:/Users/Brady/Documents/putty/;" (getenv "PATH")))
  2. Simply type Cx Cf //plink:putty-test:/ RET . 只需输入Cx Cf //plink:putty-test:/ RET Wait a moment while it connects, and window will open to dired buffer on the remote ~/ directory. 连接时稍等片刻,窗口将打开远程~/目录下的dired缓冲区。

This worked for me on : 这对我有用:

The changes from the original tramp-sh.el is 来自原始tramp-sh.el的变化是

  • for cygwin, use fakecygpty with ssh and change the prompt to ## 对于cygwin,使用scy的fakecygpty并将提示改为##
  • for plink, remove -ssh option 对于plink,删除-ssh选项

I have also renamed these method with w to differentiate it. 我还用w重命名了这些方法来区分它。

(when (string-equal system-type "windows-nt")
  (add-to-list 'tramp-methods
               `("sshw"
                 (tramp-login-program        "fakecygpty ssh")
                 ;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
                 (tramp-login-args           (("-l" "%u" "-o \"StrictHostKeyChecking=no\"") ("-P" "%p") ("-t")
                                              ("%h") ("\"")
                                              (,(format
                                                 "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
                                                 tramp-terminal-type
                                                 "##"))
                                              ("/bin/sh") ("\"")))
                 (tramp-remote-shell         "/bin/sh")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-default-port         22))
               )

  (add-to-list 'tramp-methods
               `("plinkw"
                 (tramp-login-program        "plink")
                 ;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
                 (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-t")
                                              ("%h") ("\"")
                                              (,(format
                                                 "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
                                                 tramp-terminal-type
                                                 "$"))
                                              ("/bin/sh") ("\"")))
                 (tramp-remote-shell         "/bin/sh")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-default-port         22))
               )
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM