In my ~/.ssh/config, I've got:
# BOF
Host *
User local
Host foo
HostName 10.20.30.40
User i
# EOF
When I do a "ssh foo", it tries to connect to 10.20.30.40 using
the username "local". When I remove the "Host *" lines, it tries
to connect with the username "i".
You can find a "ssh -v -v -v foo" output at http://pastebin.com/4YuFD8i4
Why does SSH do that?
I would like SSH to connect to "foo" using the username "i" and
not "local".
As to why do I have a "Host *" entry: Usually, I need/want to
connect to hosts using the username "local" (yep, l o c a l). This
is *NOT* my local username on my workstation (it's "ask"). But
for some hosts (like the "foo" one there), I'd like to connect using
a different username ("i" in this case). I know that I could of course
use "ssh i@foo", but that doesn't answer the quetion, why the "User"
line seems to be ignored...
ask@ewzw032:~> uname -a
Linux ewzw032 2.6.37.6-0.7-desktop #1 SMP PREEMPT 2011-07-21 02:17:24
+0200 x86_64 x86_64 x86_64 GNU/Linux
ask@ewzw032:~> ssh -V
OpenSSH_5.8p1, OpenSSL 1.0.0c 2 Dec 2010
ask@ewzw032:~> cat /etc/SuSE-brand
openSUSE
VERSION = 11.4
Thanks,
Alexander
This is normal regarding how openssh parse its config file: the first option
inside a matching "Host" section "wins" against all next lines with same option
Since the "Host *" matches *every* hostname, "User=local" option will always be
used in your case.
Simply put least specific host sections at the end of the file, like this:
# BOF
Host foo
HostName 10.20.30.40
User i
# global catch-all default section
Host *
User local
# EOF
--
Gilles Pion
> This is normal regarding how openssh parse its config file: the first option
> inside a matching "Host" section "wins" against all next lines with same option
[…]
> Simply put least specific host sections at the end of the file, like this:
Thanks a lot, this way it works :)
Cheers,
Alexander