Readit News logoReadit News
julienchastang · 2 months ago
I use tramp all day every b/c I mostly work on remote VMs so it is an indispensable tool. Note that tramp will allow you to go inside docker containers on those remote hosts with:

/ssh:<remote host>|docker:<docker container>

Also if you like copying (potentially large) files via dired, consider temporarily

(setq tramp-default-method "rsync")

The blog talks about rsync vs ssh a bit.

m463 · 2 months ago
It really changed my workflow with embedded linux stuff, like openwrt or raspberry pi. Instead of installing an editor on the remote system, you can use emacs on your powerful system and edit things like config files easily in a lightweight way.
zelphirkalt · 2 months ago
I don't understand what the blog post meant that rsync breaks the remote shell. Do you know what the author means? When would one want to use rsync and when scp?
celeritascelery · 2 months ago
I filed a bug report on that, and it is going to be fixed in the next Emacs release

https://lists.gnu.org/r/tramp-devel/2025-06/msg00001.html

julienchastang · 2 months ago
> When would one want to use rsync and when scp?

When moving large files.

> Do you know what the author means?

I am not sure, but I think you want ssh most of the time except when moving large files.

kristjansson · 2 months ago
Also, using persistent ssh connections makes a huge difference, esp. if you’ve got a heavy shell init on the local or remote side

  Host *
      ControlPath ~/.ssh/cm-%r@%h:%p
      ControlMaster auto
      ControlPersist 600

bqmjjx0kac · 2 months ago
I thought TRAMP overrides that setting in your SSH config.

> TRAMP uses the ControlMaster=auto OpenSSH option by default, if possible. However, it overwrites ControlPath settings when initiating ssh sessions. TRAMP does this to fend off a stall if a master session opened outside the Emacs session is no longer open. That is why TRAMP prompts for the password again even if there is an ssh already open.

https://www.gnu.org/software/emacs/manual/html_node/tramp/Ss...

dietr1ch · 2 months ago
It does and it becomes a bit annoying if you were already persisting sessions, but you can just tell emacs to use the same sockets that ssh sets up.
sunng · 2 months ago
Isn't recent Tramp versions using this by default?
PhilipRoman · 2 months ago
It's a good optimization, but be careful with it since it's not 100% compatible with the normal behavior. A master connection (the first one you establish) will not be able to close until all other connections have done so. Not all software can handle this correctly.
taeric · 2 months ago
I haven't been in a workflow where tramp is useful to me in a while. I recall it was borderline magical back when I did use it. I'm assuming it is highly reliant on how good your network connection is?

Definitely has more config now than I recall. Kudos on benchmarking the different settings here. I'm definitely curious to see what sort of stuff gets tried to make it even more seamless.

thom · 2 months ago
Just thought about this for a second and it made me sad: I haven't SSH'd into a machine in at least a couple of years at this point. Everything works through web frontends, git, CI/CD, Terraform etc. Actually editing a file on a server instead of treating everything as amorphous ephemeral compute would be a real guilty pleasure!
lotharcable · 2 months ago
Tramp can work better for containers then it does over SSH.

I use it conjunction with distrobox and podman. It should be able to work with kubernetes as well.

SoftTalker · 2 months ago
There's very little if any config that is strictly necessary. I used to use TRAMP quite a bit and I never configured anything. Of course like all emacs packages you can config and tweak it to your heart's content.
shadowgovt · 2 months ago
Tramp is how I finally got over the chronic problem of having to use vim just for remote editing files on remote machines over an ssh session. It does sometimes hang and chug inconveniently, but dealing with that is far easier than delicately holding a config file like a flower while I remember the precise vim commands (and work around the TTY special code interpretation issues that break arrow keys) to make my edits to one line.

N'ah, forget that. It's worth the setup time to make Tramp go brr.

sunng · 2 months ago
The async process sounds promising but unfortunately eglot doesn't work with it. I got a message from reddit that tramp 2.8.0-pre has fixed that issue but until last time I compiled HEAD from tramp repo it still doesn't work.

I just applied other configurations from the article and it seems faster than the default settings. Thank you author for sharing this!

Twirrim · 2 months ago
https://www.gnu.org/software/tramp/#Overview For details about tramp, in case (like me) you had no idea what tramp is.
josteink · 2 months ago
For those not into the lingo, Tramp is the Emacs module/package responsible for allowing you to transparently work on remote files and host in your local editor in a way I haven’t seen any other software do.

And yes, it’s really neat.

geocar · 2 months ago
> in a way I haven’t seen any other software do.

It was novel once upon a time, but almost every internetworked operating system supports network-transparent files. Even my iPhone can do it.

Linux is a bit weird though: VIM has netrw which is very similar to Emacs; Gnome has a special VFS API that understands URIs, but only in the loosest possible sense of the word, and it can't work with autofs to "un-URI" something into a regular unix path, which is just sad.

But if you don't care about that, autofs can make it possible to cd /net/{hostname} and get my home directory over ssh on another machine, and works much better than tramp IMO, even under Emacs.

gray_-_wolf · 2 months ago
The thing is TRAMP also gives you a shell, not just a file access. When I am in a remote buffer, I can do M-x shell, and I will get a command line running on the remote host. What is more, since the T stands for Transparent, when I want to insert e.g. output of some command into a buffer, the command is executed on the remote host and I do not have to do anything special to achieve that, it just happens auto-magically based on the directory of current file (local vs. remote). I find that useful, and you cannot really do these things with a network drive on Windows.
skydhash · 2 months ago
It's not only about transparent access. It's about how the whole emacs ecosystem working with the files. So you can bookmark a remote file, and once accessed, you can launch dired (the file manager) for the file's directory, run the shell on the remote,... with the same binding and mechanism you have for local files. No need to alter configuration or launch a special windows for the project.
sylens · 2 months ago
Thank you. I don’t know why more posts like this don’t spend a line or two providing that context
scbrg · 2 months ago
So, here's the first three sentences in the linked article:

I recently changed jobs and found myself in a position where I would need to do a lot of work on remote machines. Since I am Emacs user, the most common way to do this is using TRAMP (Transparent Remote access, Multiple Protcol). TRAMP is an Emacs package that let’s you treat a remote host like a local system, similar to VSCode Remote Development Extension.

Doesn't that provide context?

jerf · 2 months ago
Because the author had no particular expectation this would be a #1 hit on HN.
shadowgovt · 2 months ago
It is a very special piece of work. The closest I've seen is vscode remote editing (and credit where it's due: vscode remote editing is out of the box far more reliable and stable than Tramp... it better be, since it's running its own daemon on the remote machine), but Tramp is far more general-purpose than vscode's solution.

Editing as another user, editing a remote file, even editing over embedded protocols like adb: Tramp's got you covered.

shwouchk · 2 months ago
tramp is great. all the other mentioned solutions are nowhere near as seamless for “just do what i want, without distractions”.

vscode? “trust me bro, i will run a networked daemon on your server”. enjoy wondering which plugins to reinstall on your remote. enjoy installing proprietary shareware+telemetry plugins just to use git. try opening a local file and a remote file side by side in the same window. wifi connection broke for a sec? oops, you have to refresh the whole browser window.

want to edit a single file on a host you rarely connect to? enjoy spending 10 minutes setting up autosync solutions.

with any of the above - oops, you actually need sudo for that file in /etc? yeah, drop to shell and edit in vim.

there are other options to do stuff and for very specific predefined workflows they may win, but the versatility of tramp is still unmatched, especially if you do use emacs.

the only times ive had issues is when i have a weird shell setup on the remote - for that there is /sshx: instead of /ssh:

warsheep · 2 months ago
Not sure how you can compare vscode with TRAMP. A lot of dev work nowdays is done in containers where you install specific versions of dev tools, compilers, etc. Vscode is one click from seamlessly working inside such a container with its dev tools. TRAMP doesn't provide anything like that, right?
G3rn0ti · 2 months ago
Of course, you can use TRAMP to edit files inside docker containers. You don’t even need to install anything inside them.
graemep · 2 months ago
What about mounting a remote file system over sftp? Install EMACS or whatever editor you prefer on the remote?
chriswarbo · 2 months ago
> What about mounting a remote file system over sftp?

That can be OK for some tasks, but not others. For example, TRAMP will execute commands on the remote; so commands like M-x find-grep-dired will be faster when using TRAMP.

> Install EMACS or whatever editor you prefer on the remote?

There's actually a lot of flexibility there, since Emacs is perfectly usable in a text terminal, which could be run over SSH; it can also show X11 windows over the network (though I recommend the "lucid" build, rather than GTK); and it also has a client/server mode.

shwouchk · 2 months ago
installing an editor on the remote sure works - my mention of vim was not an accident, it is my preferred remote editor. some of us are bitextual ;-) - but then you lose the seamless remote+local editing, need to sync your config, potentially clash with someone else’s (ever ssh into ubuntu@awshost?), take special care not to sync any private stuff, etc.

as for sftp, unfortunately that’s not an option if you happen to use windows locally eg for work reasons, nor if you use a mac as of several years now, since fuse became closed source.

not to mention, again, the fact that you are limited to whatever root you decided to mount, limited to editing as a user that i’ve already mentioned, as well as limited from using remote tools as sibling stated. try making a git commit over sftp.

if you have a focused “working on a project” workflow it may work, otherwise PITA