问题
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
- In section Session, specify Host Name, for example
username@server
. - Go to section Connection > SSH > Auth and Browse for your "Private key file for authentication".
- Back to section Session, name your Saved Sessions, for example
putty-test
, and click Save button. - Check your connection by clicking the Open button. If it works, you can close these now.
Next, head to your Emacs.
- 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")))
- Simply type
C-x C-f //plink:putty-test:/ RET
. Wait a moment while it connects, and window will open todired
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