I use Putty to edit code romotely today. Because for some reason I can’t download or upload the files by WinSCP or something else, I can only do the coding using Emacs under Putty. It is really a bad experience using Emacs under Putty, and I don’t know why Emacs M-v keybinding doesn’t work under Putty. It is also really bad that I can’t use my own Emacs config file. I think there should be the same situation under secureCTR. It seems using Emacs Tramp is the best choice.

1. Install Putty

There is nothing to discuss about Putty installation, just do it.

2. Add Putty Installation Path to Windows System PATH

Make sure you add Putty installation path to Windows system PATH:

C:\Program Files\PuTTY

By doing it, we can let Emacs file plink.exe file.

3. Add Tramp code in Emacs Config File

Just put following elisp code into .emacs file:

(require ’tramp) (setq tramp-auto-save-directory “c:\\tmp”) (setq tramp-default-method “plink”)

4. Use Tramp to Edit Remote File

Now, we can use M-x find-file or C-x C-f to open remote file. When Emacs prompts the open info, just input the URL pattern of following:

/usr@machine:/path/to/file

For example, if you want to explore ~/main.c on remote host, you can open it with path:

/water@192.168.1.20:/home/water/main.c

Some machines use different port to provide SSH service, and in this situation we can use following URL to open file or folder:

/test@host#2222:/tmp

, which means using # to add specific port. Just write down the SSH port behind # to enable the connection.

When you are editing the remote file or folder, all the thing is the same as editing locally.

5. Tips

Although Emacs Tramp is very convinent for editing remote Linux host, it is still a better choice if you can download files and edit them locally. By this way, you can use Emacs, use more tools ( for example, Visual Studio, WinMerge, etc.) to coding, merging, copying. There is nothing happier than done the work quickly!