Emacs + tramp + plink

扶醉桌前 提交于 2019-12-06 11:32:09

问题


I'm trying to get emacs tramp running under Windows XP to work over putty plink on an Amazon EC2 instance. 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?


回答1:


(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. If I find more notes, I shall add them here.




回答2:


I'll assume you have a GNU/Linux server you want to access, a username and a .ppk file. Also, Emacs 24.4+.

First set up server in PuTTY Configuration

  1. In section Session, specify Host Name, for example username@server.
  2. Go to section Connection > SSH > Auth and Browse for your "Private key file for authentication".
  3. Back to section Session, name your Saved Sessions, for example putty-test, and click Save button.
  4. Check your connection by clicking the Open button. If it works, you can close these now.

Next, head to your Emacs.

  1. Make sure Emacs knows where your plink.exe is. 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")))
  2. Simply type C-x C-f //plink:putty-test:/ RET. Wait a moment while it connects, and window will open to dired buffer on the remote ~/ directory.



回答3:


This worked for me on :

  • Windows 10
  • Emacs found at https://sourceforge.net/projects/emacsbinw64/files/release/.
  • cygwin64
  • Putty.
  • https://github.com/d5884/fakecygpty

The changes from the original tramp-sh.el is

  • for cygwin, use fakecygpty with ssh and change the prompt to ##
  • for plink, remove -ssh option

I have also renamed these method with w to differentiate it.

(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))
               )
  )


来源:https://stackoverflow.com/questions/1095172/emacs-tramp-plink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!