Bug 2542 - Conflicting usernames by -l, -o user, user@ - it's not clear which one is used
Summary: Conflicting usernames by -l, -o user, user@ - it's not clear which one is used
Status: CLOSED DUPLICATE of bug 2835
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.7p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-18 19:19 AEDT by Grzegorz Bajson
Modified: 2021-04-23 15:10 AEST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grzegorz Bajson 2016-02-18 19:19:35 AEDT
Hi,
I couldn't find any description of the rule for choosing a right username when many usernames are provided from the command line/config file:

It seems that usernames provided with -l and ...@ override the ones from config and "-o user", and the last one is chosen.
I am not sure if this is a documentation issue or a bug.


Examples:
---------

1. "-o" overrides .ssh/config
-----------------------------
gbajson@server1:~$ cat .ssh/config  
Host localhost                      
    user=user_config

gbajson@server1:~$ ssh -o user=user-o localhost   
user-o@localhost's password:                      


2. "-l" and "@" override "-o user"
----------------------------------
gbajson@server1:~$ ssh -l user_minus_l localhost  
user_minus_l@localhost's password:                

gbajson@server1:~$ ssh user_at@localhost 
user_at@localhost's password:            


3. The last username is chosen when, both "-l" and "@" are provided
-------------------------------------------------------------------
gbajson@server1:~$ ssh user_at@localhost -l user_minus_l    
user_minus_l@localhost's password:                          

gbajson@server1:~$ ssh -l user_minus_l user_at@localhost
user_at@localhost's password:                           


Kind regards,
Grzegorz
Comment 1 Darren Tucker 2016-02-18 21:02:10 AEDT
ssh_config(5) has this at the top:

 ssh(1) obtains configuration data from the following sources in the fol-
 lowing order:

     1.   command-line options
     2.   user's configuration file (~/.ssh/config)
     3.   system-wide configuration file (/usr/local/etc/ssh_config)

does that help?
Comment 2 Jakub Jelen 2016-02-18 21:15:39 AEDT
This bug is already filled as bug #2385, but I consider both of them resolved by the commit mentioned in the other one:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sshconnect.c.diff?r1=1.260&r2=1.261
Comment 3 Grzegorz Bajson 2016-02-18 21:43:59 AEDT
Darren, this helps but doesn't explain cases (2) and (3).

Jakub, in fact this one is a duplicate.

Thank you both.
Comment 4 Damien Miller 2018-07-12 15:49:08 AEST

*** This bug has been marked as a duplicate of bug 2835 ***
Comment 5 Damien Miller 2021-04-23 15:10:20 AEST
closing resolved bugs as of 8.6p1 release