Editing remote files with Emacs using public key authentication

pico picture pico · Aug 30, 2009 · Viewed 11.7k times · Source

How can I edit files on my remote host using my local Emacs when I can access the remote host only through SSH with public key authentication? Tramp handles normal password logins pretty well but I can't figure out how to get it work with key pairs. I'm using unix/linux on both ends.

Answer

Loren picture Loren · Apr 27, 2012

There is no TRAMP equivalent to ssh user@host -i private-key.pem. However, if you run the shell command ssh-add private-key.pem, then ssh (and thus TRAMP) will automatically use private-key.pem for authentication. Simply ssh user@host will work on the shell, and opening the file /user@host:~/filename.txt will work in emacs, without it prompting for a password.