How do I connect a website via 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.
Note: If your SSH connection closes immediately, your account may be blocked for unauthorized Sudo use. Please contact support for assistance.
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
- Once you have downloaded PuTTY, search for and open PuTTY Key Generator on your computer.
- Select Generate and move the mouse around in the gray box to generate some Randomness. This will generate a public key.
- Add a passphrase (password). This is what you'll need to put into the command line interface.
- 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.
- 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.
- Head back to PuTTY Gen and select Save private key. Save this as any name you want.
- Open PuTTY. Down the left-hand side, select to expand the SSH, select Auth and then Credentials.
- 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.
- 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.
- The command line interface will then open. You’ll want to enter your domain here as your username (e.g. domain.co.uk).
- 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.
- 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.
- Open a Terminal session, and navigate to the directory that you wish to store your Public/Private Key pair in.
- 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. - 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.
- 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 becat example.pub
- 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.
- 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’. - You’ll be asked if you wish to connect using the key. Enter yes.
- 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.
- 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:
- Log in to My20i.
- Head to Manage Hosting and select Manage on the hosting package you want to connect to.
- Select the SSH Access icon.
- You’ll now need to generate a public key, on a Mac this is done via the Terminal utility. Open Terminal on the Mac.
- Enter the following command into the Terminal:
ssh-keygen
- Press Enter
- 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
- 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.
- You’ll be asked to confirm the passphrase, since we’ve left this empty just press Enter.
- 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
- Copy the path and enter the following command:
cat /Users/20i/.ssh/id_rsa.pub
- The key will be outputted, copy the whole key from the start to the end.
- 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.
- 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
Orssh 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.