make ssh remember host's username

exeral asked:

I connect to many servers daily.
my ssh config default username is "admin"

but servers comes from different environnements and username can changes. sometimes it will be "ec2-user" or "exploitation" or "something-else" …

Is there a way SSH remember that last connection to was with "ec2-user" ?

So I don’t have to specify "-l ec2-user" next time.

My answer:

You can set these up yourself in your configuration file $HOME/.ssh/config.

For example:

Host *
        User ec2-user

        User centos

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.