Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've tried setting up my ~/.ssh/config file with the help of this guide. However, the host-specific User override has no effect and ssh tries to connect using the global username instead of the host-specific one. My ssh config is set up like this:

$ cat ~/.ssh/config
User my_global_username

Host dev1
    HostName 10.40.10.41
    User my_username_on_dev_machines

I've also tried putting the global user name below a Host * entry to no avail. The OpenSSH version and build I'm running is OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 Feb 2013 `.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

There is no "global" value in .ssh/config. If you want to have a default value you have to put it in a "Host *" section:

Host dev1
    HostName 10.40.10.41
    User my_username_on_dev_machines

Host *
    User my_global_username

Note the ordering: The first match wins!

share|improve this answer
    
A couple of follow-up questions:1) Has the behavior changed recently? The guide at the linked website clearly shows Host * in the top. –  andyn Feb 18 at 12:04
    
2) The first match wins, but apparently only for those values it explicitly sets. Is this documented somewhere? Man ssh_config does not show anything related in Host or PATTERNS sections. –  andyn Feb 18 at 12:14
1  
First sentence in the second paragraph in ssh_config(5) says: "For each parameter, the first obtained value will be used." I don't know if that changed recently, but I had "Host *" at the bottom all the time. –  cran Feb 18 at 13:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.