1

I thought this should be an extremely basic question, but googling has only revealed one other question on here [1], which did not help.

I have a rather extensive ssh config. How do I get TRAMP to respect it? Most things work out of the box, except for the username, for which TRAMP prompts me for every single server. I would like TRAMP to stop prompting me and just use the "user" entry from my ssh config. Is there a setting for this?

Edit: TRAMP only prompts when the config uses canonicalisation. That is, the following ssh config works:

Host foo
  HostName foo.example.com
  User BettaGeorge

However, the following instead prompts me for a username:

CanonicalDomains example.com
CanonicalizeHostname yes

Host *.example.com
  User BettaGeorge

Setting the username per-host (without wildcards) is not an option since I manage a large cluster of occasionally short-lived virtual machines.

I have confirmed that tramp-default-user-alist is nil when this happens.

My emacs version is 27.2 on linux, my TRAMP version is 2.4.5.27.2.

[1] Tramp mode in emacs using ssh config

2
  • Check your tramp-default-user-alist for conflicting entries. FWIW, I cannot reproduce your problem. With an entry like the one Michael Albinus shows in his answer (and no conflicting entries in tramp-default-user-alist) I can access the remote host with no prompt and any one of scp, ssh, sshx protocols.
    – NickD
    Dec 3, 2021 at 6:02
  • Indeed, you are right. I can get it to work with a minimal ssh config. However, as soon as I add hostname canonicalisation, TRAMP fails. I have edited my question to provide examples. Dec 4, 2021 at 0:02

1 Answer 1

2

If you have a config like

Host xxx
  HostName yyy
  User zzz

it shall be possible to open /ssh:xxx:. Tramp uses then user name zzz and host name yyy. Does this work for you?

6
  • That's what I figured, but it does not. TRAMP prompts me anyway. As far as I understand the documentation, this is intended behaviour: "A Caution: TRAMP will override any default user specified in the configuration files outside Emacs, such as ~/.ssh/config." Cited from the html documentation: gnu.org/software/tramp/#Default-User Dec 2, 2021 at 21:28
  • 2
    What you quote only applies if tramp-default-user-alist contains an entry conflicting with the one in your ~/.ssh/config: in that case the alist entry wins; but as the doc states "To stop TRAMP from applying the default value, set the corresponding alist entry to nil".
    – NickD
    Dec 3, 2021 at 6:00
  • Which Emacs/Tramp versions are you using? Have you tried it with emacs -Q? Dec 3, 2021 at 8:33
  • tramp-default-user-alist is nil. I have pinpointed that the problem is not with usernames per se, it is with hostname canonicalisation. See my edited question for details. I have also added version information to the question. Dec 4, 2021 at 0:04
  • 1
    Tramp hasn't implemented canonicalization. I'll add it to the TODO section of tramp-sh.el, but I cannot promise any due date for implementation. Dec 4, 2021 at 8:35

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.