Emacs + tramp + putty = you can edit your UNIX files remotely “anywhere”, even on Windows

Written by

in

, ,

TRAMP extends the capabilities of the emacs “directory editor” (dired) to allow you to also deal with remote files. “Remote” as in:

  • you can reach the file or directory through ssh
  • or sftp
  • or ftp
  • or …
SSH on Windows – PuTTY:
On Windows platforms it can make use of the PuTTY family of utilities in order to achieve ssh and sftp tasks.
 

(setq tramp-default-method “pscp”)

I personally chose pscp to be my tramp-default-method on Windows with PuTTY, I “customised” it (so I don’t really do a setq as show above), and the resp. setting lives in my .emacs.d/gnu-emacs-custom.el .

… According to my experience (having tried various ways resp. methods) plink resp. plinkx occasionally corrupt files, and you avoid that using the TRAMP method pscp, which is actually a nice combination of plinkx and PuTTY pscp (??? looks weird !!!), i.e. you are passing a named saved session (→ PuTTY) rather than a host name to it. (“THE manual” does not mention this bit, but you should be aware of it.)
 

If you are able to add the PuTTY installation directory to the %Path% environment variable, this makes things easy, otherwise do it within your .emacs.d/init.el !

This also shows how to add the PuTTY directory to PATH (within .emacs.d/init.el):

 

Update 2013-01-15: tramp paths with ports:
Occasionally “sitting” on a VM (VirtualBox) host I copy / access files living in a VM Linux guest, whose SSH port is forwarded to the VM host’s port 2222.
VM-host $ env RSYNC_RSH=’ssh -p 2222′ rsync -vaz diary localhost:diary_
This is a useful emacs/tramp access path for those files:
/scpx:localhost#2222:diary

scpx and sshx as opposed to scp and ssh (without the ‘x’ in the end) seem to accept a port number within these emacs/tramp access paths.

Update 2013-04-30: problem with preserving emacs tramp file permissions:
Somebody else experiences this problem as well [link].

Update 2013-04-30 evening:
http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/pscp-filemodes.html : I think, this doesn’t concern TRAMP, as TRAMP has its own means to enquire and set file modes.

Update 2013-10-__:
Found “vc-handled-backends” and reduced it on my Windows emacs / tramp / putty platform.

Update 2017-09-08: Every now and then I come across this error message:

Cannot find local copy program: pscp

This only occurs for “bigger” files (e.g. a 40k file), not for small files, because small files are being dealt with by plink.

tramp-do-copy-or-rename-file-out-of-band (in lisp/net/tramp-sh.el) tries to find the copy-program on exec-path instead of PATH, so we have to add putty-directory to exec-path as well. I amended this page to deal with the situation:

Fixed  😆

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.