Re: How to tell tramp to use login shell in sudo multihop?

Tilmann Singer <[email protected]> Sat, 26 Apr 2025 16:07:54 +0200
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Hello Michael,

> Of course, it is possible to add a new method to tramp-methods. However,
> there are disadvantages. For example, your new method won't benefit from
> new/changed parameters of methods in tramp-methods, unless you care and
> check regularly. For the sudo method, there is on my todo list to
> empower it for direct async connections. This requires changes in
> tramp-methods.
>
> Furthermore, tramp-methods isn't the only change for method
> configuration. For the sudo method, we configure also
> tramp-default-user-alist (default user "root"),
> tramp-completion-function-alist (user/host name completion), "~/" in
> expand-file-name, tramp-default-proxies-alist (multi-hop
> configuration). I don't know whether you need this for your own method,
> but you see, it is rather complex.

Thanks for clarifying. It is indeed complex – a custom method is
definitely the wrong approach for my use case then.

> Instead, the Tramp manual recommends to adapt a parameter for a given
> method of tramp-methods, specific to a remote target (a regexp). See the
> discussion in (info "(tramp) Predefined connection information") . In your
> case, I recommend you to apply
>
> --8<---------------cut here---------------start------------->8---
> (add-to-list 'tramp-connection-properties
>              (list (regexp-quote "/sudo:user@host:")
>                    "login-args"
>                    '(("SUDO_PROMPT=P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":")
>                      ("sudo") ("-u" "%u") ("-i") ("%l"))))
> --8<---------------cut here---------------end--------------->8---

Cool, this works now. I've tried something similar before, but couldn't
get it to work. Turns out, the combination of this setting, adding
'tramp-own-remote-path to 'tramp-remote-path and a call to
tramp-cleanup-all-connections did the trick.


cheers, Til
signature.asc (application/pgp-signature, 853 B)
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCAAsFiEEXoajwlwFeMDQ1WTwuGOMJcql3BYFAmgM6LoOHHRpbHNAdGls
cy5uZXQACgkQuGOMJcql3BaZBw//RAEzuXUCtpkMDVCGRxpcdgoUKEWG1DSP5HpX
4d8LQ0rt5k8lnkyZaZnCUUXRQZcbLgHa3790js74gfAQ8gas474bo5Lf0a+7pwt8
976t66O6l0DFyPSvUSZ1pds6C89cdcSYmDtXhljenq5dl5hlMeTBLWj+Oa3e2JQc
zR+xH1BK7Q/NFUkCh7b52sxTPrQkABzWkqa21kLstZfXZ8r9nCkgP16HjJ5gxZ5q
TfwyZ4+Gvt3I3yeckwSJhFFvTgK7YGFxQt6YdwZ1EAYf7q7NnJ6XQGbWJ8jNdEOC
1/b6Q8bg9c4Q+jSRofhsj1fN7Yc2RWOQ75nSEgVvqnP870bpqKzNIIAUThoNmDdD
l66T7ICKg+lwgcUtaUSO11Ovz10okmYj+6k8qaojQLdpBjSsPgBPBdgAAwz1uhCs
f1B7lH8zsUdwgCfIynQSajMgr2kgLtdVSVL4SUgs6eXbd09cpX2IDB2k4v+DliG2
0h6izfks/G6c8SigOPITsE658kaiylefsTK4Vy6oJID8PvZNIQFoMHzWwLSci1kG
aGCA0V6JozB+JHVcZjJCJAeSKBPLBdPpS0MQihZ8xeWgJ8f27UaUereyYFP5HM25
cHT0FPVLUMrgLddXaeGv8IehScjuSy4q8E1xSmEluEgiK9is4DHEYBcHyb+ae5Vf
qv5bJKg=
=aM3c
-----END PGP SIGNATURE-----