0

I am new to Emacs. I run Linux. I'd like to tramp into a Windows machine, so that I can edit the files on the Windows machine from the comfort of my Linux system. Apparently, you have to change the shell used by ssh on the Windows host for it to work.

I found pages that tell me how to do that with snippets of configuration here: https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-shell-setup.html and so I would like to add this to tramp's configuration:

(add-to-list 'tramp-connection-properties
    (list (regexp-quote "/sshx:windowsusername@windowshost:")
        "remote-shell" "git-bash.exe"))

But I have no idea in what file I should put this. I tried to create a /home/username/.emacs.d/init.el file and I wrote the snippet above inside that file. But that makes no change (the default shell /bin/sh is still used and that makes the tramp session fail). So I guess I'm not putting that snippet in the correct location.

I've searched for more general information about tramp configuration. This seems to be the main page, again, with examples of customization snippets: https://www.gnu.org/software/emacs/manual/html_node/tramp/Configuration.html

But where should they go?

Should I create an init.el file in /home/username/.emacs.d and add the tramp configuration directives there (that didn't seem to work) ? Or is there a tramp specific configuration file ? Or should I put this in /home/username/.emacs ? Or in a directory specific to tramp inside /home/username/.emacs.d ?

9
  • (FWIW, your regexp-quote isn't needed for the arg you give it here.)
    – Drew
    Commented May 21, 2023 at 22:35
  • start emacs after saving random text in your init.el and if it is loaded from the location, fatal error will occur.
    – roomworoof
    Commented May 22, 2023 at 2:30
  • The remote shell shall be an absolute path. "git-bash.exe" is a relative path only. Commented May 22, 2023 at 14:54
  • 2
    Emacs looks for an init file in various places and it uses the first one that it finds. So if you have both a ~/.emacs and an ~/.emacs.d/init.el, only the first one will ever be effective. You need to delete the first one in order for Emacs to use the second one - and so on down the line. You can ask Emacs what init file it is using to make sure: C-h v user-init-file.
    – NickD
    Commented May 22, 2023 at 16:48
  • 2
    Nothing stops you: I have many config files and my init.el is pretty much a list of requires of those config files. OTOH, tramp.el is not a configuration file for tramp: it's the top level code.
    – NickD
    Commented May 23, 2023 at 19:15

1 Answer 1

0

If you want to access an MS Windows machine from Linux via Tramp, you're better with the smb method. This doesn't need any remote shell.

2
  • Will I be able to use the C# language server with eglot that way? I would guess this requires ssh access, not just file access. Commented May 22, 2023 at 10:19
  • No. The smb method doesn't support remote processes. Commented May 22, 2023 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.