In a discussion over a beer, a friend of mine asked whether I know a way to edit remote files over
ssh? It was then that I realized that my long time obsession with Emacs is starting to pay off and I gave him the only way I know how to do that: Emacs and Tramp Mode.
This is how I do it.
Emacs 25.2 on Kubuntu 17.04 and on Windows 10 using Cygwin and when working with remote files both systems behave the same.
- Configure the remote machine to authenticate you with a key file as specified in this stackoverflow answer
- Start Emacs
To open the remote file for editing invoke the
find-file command either using
C-x C-f (
C = Ctrl) or with
M-x find-file (
M=Alt) and at the file prompt specify the path in the following format:
To exemplify let's consider the following scenario: I have a virtual machine with the IP
192.168.13.13 to which I can connect remotely with
ssh using the username
petru and the default public key (~/.ssh/id_rsa.pub). On that machine I want to edit the file
To do so, I open the file as usually in Emacs using
C-x C-f and at the prompt (the minibuffer) I enter the following: