# Default SSH User: setting a default username for a particular ssh host.

posted 2012-Mar-8

On all of my personal machines—and on this server—I have the same username (phrogz). Thus, when I’m at home and I want to ssh into my server, I can simply type:

ssh phrogz.net


…and it automatically connects as phrogz@phrogz.net since that’s the current username.

At work, however, I have a different username. Thus, if I type ssh phrogz.net it attempts to connect as gkistner@phrogz.net, which fails. Now, I could just type ssh phrogz@phrogz.net (and did, for years) but that doesn’t stop my muscle memory trained at home from typing the wrong thing first. Today, I fixed it:

1. Create a file named config in the .ssh directory in your home directory. On Windows 7 this is \Users\gkistner\.ssh\config.
2. In that file, put the following content:

Host phrogz phrogz.net
HostName phrogz.net
User phrogz


Voila! Now when I type ssh phrogz.net it connects using the correct username. As a bonus, due to the phrogz on the Host line, I can also just type ssh phrogz and it automatically resolves to the correct address.

Even moreso, this works with other commands that use ssh, like scp: scp foo.js phrogz:js/libraries/

For more information, read up on man ssh_config.