I’ve been using SSH for a very long time, and that habit is pretty much ingrained in me.  However, when I’m on my MacBook or iMac, those usernames don’t tend to be the same as my Linux servers. This means that command then turns into something like this, where Username is the username on the remote server: Okay, that’s not a huge difference, and adding a username to the command doesn’t take that much extra time. However, when you’re in and out of servers all day, that time adds up. On top of which, when you realize (for the tenth time that day) you’ve forgotten to add the username to the SSH command, it can be frustrating to have to [Ctrl]+[C] out of the command and retype. Also: Don’t waste your money on these Apple products Fortunately, there’s a way around that. With SSH, there’s a user-specific config file that allows you to set a default username for all of your SSH connections. In that configuration file, you can create entries for individual connections. An individual entry might look something like this: In the above configuration, the following options are explained:

Host: The nickname used for the connection (so you could connect with simply ssh ubuntu-invoice).User: The username for the connection.Hostname: The IP address or domain for the connection.IdentityFile: If you use SSH key authentication, this defines the key file used.

You can set up individual entries for every remote machine you connect to via SSH in this way, and it doesn’t matter how many entries you add to the file. On top of that, every entry can have different options. However, we’re talking about setting a default username for all of your connections. Once you’ve set this option, any time you issue an SSH command without a username, it will assume what is set as the default in the config file is the username to apply. However, if you have individual entries that include a username, those entries will preempt the default.  Also: The 6 best Macs What do I mean by that? Let’s say you set the default SSH username in the config file to jack. Also, in the config file, you have this entry: If you issue the command ssh microk8s, SSH will apply the olivia username to the connection. Let’s get this configuration up and running.

How to set up an SSH username in MacOS

Once you’ve added that entry, save and close the file with the [Ctrl]+[X] keyboard combination. Also: The basics of SSH usage Now, when you go to connect to any server via SSH, you can leave out the username in the command. Of course, if the remote username is different than the default you’ve configured, simply add it to the command, bypassing the default configuration.