Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing remote files with Emacs using public key authentication

Tags:

emacs

ssh

tramp

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.

like image 290
pico Avatar asked Aug 30 '09 07:08

pico


2 Answers

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.

like image 136
Loren Avatar answered Oct 07 '22 15:10

Loren


I don't get your question as Tramp works perfectly well with public-key authenticated SSH connections. For instance, assuming you have set the following config in ~/.ssh/config:

Host remotehost     User     mylogin     Port     22     Hostname remotehost.fqdn 

and assuming that you can run ssh remotehost correctly in a terminal, then you are able to open your remote file using TRAMP C-x C-f /remotehost:path/to/file

like image 27
Sebastien Varrette Avatar answered Oct 07 '22 15:10

Sebastien Varrette