How do I connect a website via SSH?

Ruth Turner
Published: 11 September 2017Last updated: 14 March 2024
Share:

What is SSH?

SSH, or ‘Secure Shell’, is a method of remotely accessing and managing your site files, as well as allowing for configuration changes and remote command execution within your file space. SSH on the 20i platform is encrypted, and protected by either 2FA or public/private key pairs to validate the connection, making it reliable and secure. 

Below are instructions for connecting to your site via SSH for Windows, Apple Mac and Linux devices using public/private key pairs. If you wish to connect using 2FA, please see our guide How do I connect to SSH using 2FA?

Note: It's only recommended that you connect to your package via SSH if you're familiar with the command line interface. 

Windows

If you're using Windows, you'll need to download an SSH Client to access SSH.

Note: This guide uses PuTTY which is a free SSH client for Windows and can be downloaded here:

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

  1. Once you have downloaded PuTTY, search for and open PuTTY Key Generator on your computer.
  2. Select Generate and move the mouse around in the gray box to generate some Randomness. This will generate a public key.
  3. Add a passphrase (password). This is what you'll need to put into the command line interface.
  4. Log in to My20i, head to Manage Hosting and select the package that you want SSH access for. Then select, SSH Access from under the Security section.
  5. Then input the public key that was generated from PuTTYgen into the Public Key box. A handle will be generated automatically. Then select Add Public Key.
  6. Head back to PuTTY Gen and select Save private key. Save this as any name you want.
  7. Open PuTTY. Down the left-hand side, select to expand the SSH, select Auth and then Credentials.
  8. There should be an area labelled Private key file for authentication – select Browse next to this and add the private key you have just saved.
  9. Head back to Session using the left-hand menu and add the SSH host name. The hostname you wish to use depends on what data center you’re using. For the UK data center, use ‘ssh.gb.stackcp.com’, and for the US use ‘ssh.us.stackcp.com’. Then, once that has been added, select Open.
  10. The command line interface will then open. You’ll want to enter your domain here as your username (e.g. domain.co.uk).
  11. You'll then be prompted for the passphrase that you set earlier. Enter this in the prompted area – PuTTY will hide the characters being entered for security purposes, so do not worry if any input doesn’t seem visible.
  12. You'll then be logged into your account and have full access to your SSH area on your site.

Linux

Connecting to SSH on Linux will require you to set up a Public/Private Key pair on your local machine, add it to the SSH area on your package and then connect using the details provided.

  1. Open a Terminal session, and navigate to the directory that you wish to store your Public/Private Key pair in.
  2. Enter the command ssh-keygen and follow the on-screen prompts – the tool will prompt you for a name for the file, as well as setting a password. This is what you'll need to put into the command line interface later, so make note of it once set.
  3. Once the files have been created by the process, log in to My20i, head to Manage Hosting and select the package that you want SSH access for. Then select, SSH Access from under the Security section.
  4. Back in your Linux terminal, use the command cat to view the contents of your public key file. This will be the file ending in .pub that was generated by the command earlier and should use the name you set. 

    For example, if you chose to name your key example, the command to open it would be cat example.pub
  5. Copy the contents of the file, and paste it into the Public Key box in the SSH area on My20i. A handle will be generated automatically. Then select Add Public Key.
  6. Now that you’ve got your public key added to My20i, you can connect via SSH by using the command:

    ssh -i keyname hostname

    Where keyname is the name of your private key file you entered earlier. The hostname you wish to use depends on what data centre you’re using. For the UK data centre, use ‘ssh.gb.stackcp.com’, and for the US use ‘ssh.us.stackcp.com’.
  7. You’ll be asked if you wish to connect using the key. Enter yes.
  8. You'll then be prompted for the passphrase that you set earlier. Enter this in the prompted area – PuTTY will hide the characters being entered for security purposes, so do not worry if any input doesn’t seem visible.
  9. You'll then be logged into your account and have full access to your SSH area on your site.

MacOS

To connect via SSH on a Mac you can follow this video or the instructions below:

  1. Log in to My20i.
  2. Head to Manage Hosting and select Manage on the hosting package you want to connect to.
  3. Select the SSH Access icon.
  4. You’ll now need to generate a public key, on a Mac this is done via the Terminal utility. Open Terminal on the Mac.
  5. Enter the following command into the Terminal:
    ssh-keygen
  6. Press Enter
  7. You’ll be prompted to enter the location that you want the public and private keys saving. In this case, we’ll keep this as the default location. Press Enter
  8. You’ll be prompted for a passphrase, in this guide we’ll just leave this empty. If you enter one, make sure you remember this as you’ll be prompted for this later. Press Enter.
  9. You’ll be asked to confirm the passphrase, since we’ve left this empty just press Enter.
  10. Your keys will have been generated and the public key will have been saved in a specified location, in our example it has been saved in:
    /Users/20i/.ssh/id_rsa.pub
  11. Copy the path and enter the following command:
    cat /Users/20i/.ssh/id_rsa.pub
  12. The key will be outputted, copy the whole key from the start to the end.
  13. Paste the key back in My20i in the Public Key field in the SSH Access section. The handle should be added automatically. Press Add Public Key. Please note that can take up to 5 minutes.
  14. Head back to Terminal and enter the SSH username and hostname found at the top of the SSH Access section, it should be something like domain.com@ssh.gb.stackcp.com for packages in the UK, and domain.com@ssh.us.stackcp.com for packages in the US. You’ll need to prefix it with the ssh command as follows:
    ssh domain.com@ssh.gb.stackcp.com
    Or
    ssh domain.com@ssh.us.stackcp.com

You’ll be prompted to confirm you would like to connect, simply type yes and press enter.

You should have successfully connected via SSH from your Mac to your hosting package at 20i.