You probably use SSH to connect to remote machines for admin purposes. Generally speaking, SSH is quite easy to use. Open your macOS terminal app and issue a command like:
As long as your usernames are the same on both ends, you’re good to go, but if your user names aren’t the same, that command might look like:
Now, what happens if you remote into 10 or 20 different machines throughout the day, each with different usernames and IP addresses? That can get a bit confusing after a while. What if I told you that SSH can use a configuration file to make it much easier? By making use of the SSH configuration file, you can configure an entire data center worth of SSH connections such that you could issue a command:
How do you do that on macOS? Let me show you.
SEE: Identity theft protection policy (TechRepublic Premium)
What you’ll need
The only thing you’ll need is a MacBook or iMac that includes SSH and some remote servers to connect to. With those at the ready, let’s make this happen.
How to create the config file
Open the macOS terminal app. Once it opens, change into your user SSH directory with the command:
In that directory, create the new file with the command:
Let’s create our first configuration. For example, say this is a Nextcloud server at IP address 192.168.1.20 and the username is vega. We’re going to name this server “nextcloud” so we can easily remember how to Secure Shell into it. We’re also going to enable key authentication for the connection.
This configuration will look like:
If you’re not using SSH KEY authentication (which you should), you’d need to remove the IdentityFile line.
Save and close the file.
To SSH into our Nextcloud server, you’d only have to type the command:
You can create as many configurations in that file as you need (one for every server in your data center), each with different options. Just make sure, at a minimum, you include the Host and Hostname options. This makes it so much easier for you to remote into those servers from your Apple laptop or desktop.
Let’s say you use the same account on all of your data center servers on the IP address scheme 192.168.1.x. You could configure that at the top of the config file with two simple lines:
Where USERNAME is the user on the remote machines.
You could then create each host configuration entry (below that), leaving out the User option, like so:
Save the file and you’re ready to SSH into those machines with commands like:
And that’s all there is to creating an SSH config file to be used on macOS.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.