Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Last active November 6, 2022 11:06
Show Gist options
  • Save EricBusch/62a4bba94d5a4ebd7add5ef361d43bd1 to your computer and use it in GitHub Desktop.
Save EricBusch/62a4bba94d5a4ebd7add5ef361d43bd1 to your computer and use it in GitHub Desktop.
Here are instructions on setting up SSH access on SiteGround using a Mac.

Open the Terminal app on Mac.

Change directories so that you are in your user's .ssh directory. For example, my user directory is named "Eric" so I would type the following into Terminal:

cd /Users/Eric/.ssh

Now you need to generate your SSH key pairs. Enter the following command into Terminal (source 1, source 2):

ssh-keygen -t rsa

After you enter that command, you will see something like this:

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/Eric/.ssh/id_rsa): 

To save the file in /Users/Eric/.ssh/id_rsa, just hit the [Enter] button.

To save the file under a different name or path, change it here. (Optional)

Next, you'll see something like:

Enter passphrase (empty for no passphrase):
Enter same passphrase again: 

Enter a passphrase and write it down somewhere so you have access to it in the future.

IMPORTANT - Be sure to save your passphrase. You will almost certainly be prompted for it again at some point in the future. If you don't have it, you'll have to repeat all of these steps again.

After entering your passphrase twice, you'll see something like this:

Your identification has been saved in /Users/Eric/.ssh/id_rsa.
Your public key has been saved in /Users/Eric/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ywju3VmgWcTtV2DqipxgfjaJ2tANnVtLsfC+tKsxGmb
The key's randomart image is:
+---[RSA 4096]----+
|                 |
|     .           |
|    . .          |
|o.   - = O       |
|=. ) . Oo        |
|*^$# _        |
|%*- -.* +        |
|B+.  o.o         |
|   =E.  ....     |
+----[SHA256]-----+

While you are still in the .ssh directory, enter the following command into Terminal to load your key:

ssh-add /Users/Eric/.ssh/id_rsa

You'll need to enter your passphrase (from above) again.

Then you should get a message like this:

Identity added: /Users/Eric/.ssh/id_rsa (/Users/Eric/.ssh/id_rsa)

Now you need to copy the contents of the id_rsa.pub file. So type the following into Terminal:

cat id_rsa.pub

You should see a long string like this:

ssh-rsa AQACAFABAEADABA ......... giBb67ptKsxGLQJiZCkaPNNWLRYpew664AombyLMQKZBpN==

Copy the entire string being sure not to copy the contents above or below the string.

Now it's time to open your website's cPanel. To access your cPanel open http://YOURSITE.com/cpanel in a web browser. After you log into your cPanel, go to SSH Manager.

In the Upload SSH key section, paste the long string you copied into the Public Key field.

If you want to restrict access to a specific IP Address, enter your IP Address in the IP Address field. (Optional)

Once you've pasted in your public key and optional IP address, click the [Upload] button.

You are done with cPanel now.

Go back to Terminal. You should now be able to SSH into the server using the following command (source):

ssh USER@HOST_NAME -p PORT

  • Change USER to the username you use to log into your site's cPanel.
  • Change HOST_NAME to your server's IP Address.
  • Change PORT to 18765

So in my case, I would enter something like this:

ssh eric@123.456.789.01 -p 18765

You should get a message like this if this is the first time:

The authenticity of host '[123.456.789.01]:18765 ([123.456.789.01]:18765)' can't be established.
ECDSA key fingerprint is SHA256:xRRqYyzEpvEgiBb67ptKsxGmbyLMQKZBpNizuNgcg7ch.
Are you sure you want to continue connecting (yes/no)?

Type the word yes into Terminal to confirm.

Now you should be successfully logged in and should a command line prompt looking something like:

eric@c12345 [~]#

Now you can run commands.

When you are done, type the word exit in order to close your SSH session.

@dontait
Copy link

dontait commented Mar 19, 2017

thx - perfect and clear - much easier to follow than Siteground's FAQ

@datafeedr
Copy link

datafeedr commented Mar 31, 2017

Cool, glad it worked for you!

IMPORTANT - For anyone reading this, be sure to save your passphrase. I just got prompted for my passphrase again by Terminal but couldn't find it. So I had to redo all of the steps above... I've updated the article accordingly.

@dandange8005
Copy link

great instructions, nice the clear and easy to follow

@mijimoco
Copy link

thx - perfect and clear - much easier to follow than Siteground's FAQ

agreed. much better explanation then Siteground's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment