How to make ssh log in as the right user?

You can create a config file in your home .ssh directory, which can specify a default user, identity file etc and assign it to an alias which you can use to connect.

For example, you could put this into the ~/.ssh/config file:

Host example
    HostName example.com
    User first_last
    IdentityFile ~/.ssh/example_rsa
    Port 22
    RSAAuthentication yes
    PubkeyAuthentication yes

Host example2
    HostName example2.com
    User last_first
    # other parameters as needed

Then you can just type ssh example or ssh example2 on the command line to connect.

So you can set one up for each machine you want to connect to, with the relevant user. Then just use the aliases to connect without having to specify a user. You can also use a pattern to match multiple hosts.

There's more information, and details of what you can specify in a config file in the ssh_config man page.


According to Rich Adam's answer I found out for PuTTY where it stores its settings.

It's all stored in a registry tree, you'll find it under HKEY_CURRENT_USER\Software\SimonTatham (Simon Tatham is the developer of PuTTY).
There you can see how a host is defined.


If you want to change it for EVERY site:

Edit your ~/.ssh/config to have this:

Host *
    User buck