Betta George
Betta George

Reputation: 231

How do I make TRAMP use the usernames from my ssh config with hostname canonicalisation?

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

Upvotes: 1

Views: 536

Answers (1)

Michael Albinus
Michael Albinus

Reputation: 1656

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?

Upvotes: 2

Related Questions