Learn how to Use an SSH Config File on macOS for Simpler Connections to Your Information Heart Servers


Jack Wallen reveals you the way to make SSH connections even simpler out of your macOS machine.

You most likely use SSH to connect with distant machines for admin functions. Typically talking, SSH is kind of simple to make use of. Open your macOS terminal app and subject a command like:

ssh 192.168.1.20

So long as your usernames are the identical on each ends, you’re good to go. But when your usernames aren’t the identical, that command would possibly appear to be:

ssh vega@192.168.1.20

Now, what occurs when you distant into 10 or 20 totally different machines all through the day, every with totally different usernames and IP addresses? That may get a bit complicated after some time. What if I advised you that SSH can use a configuration file to make it a lot simpler? By making use of the SSH configuration file, you possibly can configure a whole information middle value of SSH connections such that you might subject a command:

ssh web1

Or:

ssh db1

How do you do this on macOS? Let me present you.

SEE: Use TechRepublic Premium’s identification theft safety coverage.

Instruments wanted

The one factor you’ll want is a MacBook or iMac that features SSH and a few distant servers to connect with. With these on the prepared, let’s make this occur.

Learn how to create the config file

Step 1: Change SSH listing

The very first thing it is advisable do is to alter your person SSH listing.

To do that:

  1. Open the macOS terminal app.
  2. Subsequent, turn into your person SSH listing with the command:
    cd ~/.ssh

Step 2: Create new file

You’ll now must create the primary configuration.

  1. Within the listing you modified within the step above, create the brand new file with the command:
    nano config
  2. Subsequent, create your first configuration. For instance, say it is a Nextcloud server at IP tackle 192.168.1.20 and the username is ‘vega’. We’re going to call this server ‘nextcloud,’ so we are able to simply keep in mind the way to Safe Shell into it. We’re additionally going to allow key authentication for the connection. This configuration will appear to be:
    Host nextcloud
    HostName 192.168.1.20
    Person vega
    IdentityFile ~/.ssh/id_rsa
  3. For those who’re not utilizing SSH KEY authentication (which it’s best to), you’ll must take away the IdentityFile line.
  4. Save and shut the file.

Step 3: SSH into server

  1. To SSH into our Nextcloud server, you’ll solely must sort the command: ssh nextcloud
  2. Subsequent, create a configuration in that file for each server in your information middle, every with totally different choices. At a minimal, you want the Host and Hostname choices. For instance, let’s say you utilize the identical account on your entire information middle servers on the IP tackle scheme 192.168.1.x. You would configure that on the prime of the config file with two easy traces:
Host 192.168.1.*
Person USERNAME

The place USERNAME is the person on the distant machines.

  1. Then, create every host configuration entry beneath that, leaving out the Person choice, like so:
Host nextcloud
HostName 192.168.1.20
IdentityFile ~/.ssh/id_rsa

Host web1
HostName 192.168.1.25

Host db1
HostName 192.168.1.100
IdentityFile ~/.ssh/db_rsa.pub
  1. Save the file, and also you’re able to SSH into these machines with instructions like:
ssh nextcloud
ssh web1
ssh db1

And that’s all there may be to creating an SSH config file for use on macOS.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles