Default SSH User: setting a default username for a particular ssh host.
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
email@example.com 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
firstname.lastname@example.org, which fails. Now, I could just type
ssh email@example.com (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:
- Create a file named
.sshdirectory in your home directory. On Windows 7 this is
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