Super Simple Steps for Setting Up SSH Access on a Mac: Siteground

November 13, 2023
Git
LinkedInTwitterFacebookEmail

Back in October 2020, I wrote a post about how to set up SSH in a Cpanel. If you’re looking for that setup, you can check out the article here: How to Set Up and Connect to a Website/Server with SSH Keys.

In this article, I thought I’d go a little more specific because the steps are really basic once you get a handle on it.

SSH is used to connect to a server through the Terminal/Command Line. If you aren’t familiar with the Terminal, there’s a quick overview at the top of this article: Running SASS on Localhost using the Command Line. But you should be careful, since you can really screw things up using the command line.

Super Simple Steps for SSH Access

  1. Set up SSH Keys on Siteground
  2. Copy and paste the PRIVATE key into a file in the .ssh folder
  3. Double-check the file permissions
  4. Add this Private Key to the config file
  5. Create your SSH command using this setup (replace with your deets): SSH username@server.siteground.biz -p 99989
  6. Paste into the Command Line/ Terminal and approve the connection (type yes).
  7. WIN

It’s not that difficult, as you see above, so let’s cover each step:

SSH Keys Manager in Siteground

1. Set up SSH Keys on Siteground

As of November 2023, you can find the SSH Keys Manager under the DEVS section in your Site Tools. Generate a new one, making sure the name is recognizable for your (ie. server name or site name), and the password is saved somewhere.

To the right of where you’re creating it, you’ll see your server and your username. You’ll need those soon.

2. Copy and paste the PRIVATE key into a file in the .ssh folder

After a new SSH key is created, click the three dots under “Actions” and choose “Private Key”. Leave open, you’ll by copying this text in a minute.

Open up your Finder on your Mac, and navigate to your User’s Primary Folder. (Macbook Pro > Macintosh HD > Users > Your Name). If you don’t see the hidden files and folders (.ssh), click Command > Shift > . (Period)

Open up the folder: .ssh

Create a file using a text document, or copy one already here. Make sure to name the file the same name as the SSH key you set up in the first step. You don’t want it to have any file extension: do not use .pub, .txt, or .jpg, etc.

Copy the Private Key at the beginning of this step and paste just that into this file. Paste it exactly as is and do not add or remove anything.

SAVE.

permissions

3. Double-check the file permissions

Right click on that file you just created and choose “Get Info”. At the bottom, you should be able to see the permission.

Your user should have Read & Write.

Everyone should have No access, and no other lines should exist.

If one does, Click the Lock icon at the bottom right and put in your computer’s password. Then click on the line that shouldn’t be there and choose the “-” symbol below.

4. Add this Private Key to the config file

Next we’ll adjust the config file. If you don’t have one in this folder (the same folder: .ssh), you can create one. Again, don’t use any file extensions – just name it “config”.

As you add private keys, you’ll need to distinguish which server which look at which key here. This file is how you do that easily.

Host hostname.siteground.dev
      IdentityFile ~/.ssh/name_of_key_you_just_created

Copy and paste the above into the file. User the server (up at the top, step 1) in the “hostname.siteground.dev” section. Add the name of the SSH key you created in the obvious place above. Make sure the IdentityFile line is indented one tab.

Save.

5. Create your SSH command using this setup

Now let’s create your specific SSH command for this server: SSH username@server.siteground.biz -p 99989

The last number is the port. You can find the port in the Siteground SSH settings in step 1. It’s usually about 5 numbers for Siteground.

The username is also found in Step 1. This is not the title of the private key file you added to the .ssh folder, but the username provided by Siteground in the first step.

6. Paste into the Command Line/ Terminal and approve the connection

Copy and paste, or type in, the SSH command for this server into your Terminal. You’ll get a question like this:

This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type yes.

Some issues that might arise:

  1. Permissions 0644 for ‘/Users/youruser/yourssh’ are too open. Go back to step #3. Make sure your ssh file matches the permission show in the pic (only you have access, everyone has no access).
  2. Permission denied (publickey). Go back to step 4. The server doesn’t know which SSH Private Key to match, so it’s not able to give you access. Make sure you have added the correct file name to the config file. Make sure you name your file in .ssh folder the same as you named the key you created in step 1. Make sure none of these files have extensions.

7. Win.

Congrats! Your SSH key is set up. Now you can connect to your server for git, for remote access, or for a fun Saturday afternoon activity.

Join the Discussion

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>