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:


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

At work, however, I have a different username. Thus, if I type ssh it attempts to connect as, which fails. Now, I could just type ssh (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
    User phrogz

Voila! Now when I type ssh 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.

net.mind details other résumé contact