Adding SSH Public Key

This guide walks through how to add a public key to a Siteground hosted website, then setting up passwordless login via SSH/Terminal and Transmit on a Mac.

Generating an SSH Key Pair

  1. Open Terminal
  2. Check for an existing key pair by doing: ls -al ~/.ssh
  3. Paste the text below, substituting in your email address: ssh-keygen -t rsa -b 4096 -C
  4. This creates a new ssh key, using the provided email as a label Generating public/private rsa key pair.
  5. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
    Enter a file in which to save the key (/Users/*you*/.ssh/id_rsa): *[Press enter]*
  6. At the prompt, type a secure passphrase if applicable:
    Enter passphrase (empty for no passphrase): *[Type a passphrase]*
    Enter same passphrase again: *[Type passphrase again]*
  7. Copy the SSH key to your clipboard by doing a pbcopy < ~/.ssh/ If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don't add any newlines or whitespace.

Helpful Links:

Add public key to Siteground website

  1. Find the Siteground login UN/PW in the GSL LastPass Shared Folder
  2. Login to Siteground with the client’s credentials
  3. Click over to the “My Account” tab
  4. Click the red “Go to cPanel” button
  5. Click the SSH/Shell Access icon under Advanced
  6. Paste the staff member’s public key into the “Upload SSH key” box
  7. Click the upload button

Helpful Links:

Add login to .ssh config file

  1. OpenTerminal and do a: nano ~/.ssh/config
  2. The config file should already have some defaults in it that look like:
    Host *
     Compression yes
     IdentityFile ~/.ssh/id_rsa
  3. Template for what to add to the config file:
    Host shortcutname
     Port 5555
     User username
  4. Notes:
    • Host shortcutname should be something that makes sense for the client/server
    • Hostname, Port, and User should come from the host provider
  5. Hit control-X to exit the editor, follow onscreen prompts to save the file
  6. Do a cat ~/.ssh/config to make sure changes were made

Helpful Links:

Add login to Transmit FTP Client

To-Do, but also pretty straight-forward

Add login to Sequel Pro

  1. Use a “Standard” connection — SSH connection won’t work and isn’t needed
  2. On a Siteground server you'll need to add your public IP address to the Remote Database Access Hosts list in cPanel, found in the Databases section.
    • Use the server's secondary IP address in Sequel Pro which should be listed on the Remote Database Access Hosts page
    • Username and PW for each DB user will grant access to whatever databases that user has access to. Entering a database name here will only make that the default, leave blank to not have a default
    • Port: 3306

Add remote server to Macfusion using SSHFS

I don't use this often, or really ever. These days it's all about using the Coda 2 IDE to connect to a remote server (SSH supported!) and work either locally or straight on the server, depending on what I'm doing. Nearly everything is kept in version control, as well. But I'll leave these here for posterior.

  1. Open up Macfusion
  2. Click the ‘+’ icon and choose SSHFS
  3. Add Host and Username in the SSH tab, Password and Path can be blank
  4. Add the port in the SSH Advanced tab, other fields are fine as default
  5. Enter the client key in all caps in the Volume Name field on the Macfusion tab
  6. Click Okay
  7. Mount!

This page was last updated: 10-28-2019