Hosting Guides

How to Connect to Your Website via SSH

Connect via SSH - Mamdali Technology guide

SSH (Secure Shell) lets you remotely manage your website files, make configuration changes and run commands inside your hosting file space. The connection is encrypted and protected by a public/private key pair, so it is both reliable and secure. This guide shows you how to connect via SSH from Windows, Linux and macOS.

Please note:

  • We only recommend SSH if you are comfortable using the command line.
  • It can take up to 30 minutes for your public key to be fully set up on the system.
  • If your SSH connection closes immediately, your account may have been blocked for unauthorised sudo use. Contact our support team and we will help.

Before you start: add your public key

On every system you first create a key pair on your own computer, then add the public key to your hosting package. Keep the private key safe and never share it.

  1. Log in to your hosting control panel and open Manage Hosting.
  2. Select Manage on the package you want SSH access for.
  3. Under the Security section, select SSH Access.
  4. Paste your public key into the Public Key box. A handle is generated automatically. Select Add Public Key.

At the top of the SSH Access page you will also find the hostname and port to connect with. If no port is shown, use port 22.

Connect via SSH from Windows (PuTTY)

Windows needs an SSH client. This guide uses PuTTY, a free SSH client for Windows.

  1. Install PuTTY, then search for and open PuTTY Key Generator (PuTTYgen).
  2. Select Generate and move your mouse around in the grey box to create randomness. Your public key is generated.
  3. Enter a passphrase. You will need it every time you connect, so remember it.
  4. Copy the public key from PuTTYgen and add it on the SSH Access page, as described above.
  5. Back in PuTTYgen, select Save private key and save it under any name you like.
  6. Open PuTTY. In the left-hand menu expand SSH, select Auth, then Credentials.
  7. Next to Private key file for authentication, select Browse and choose the private key you saved.
  8. Go back to Session in the left-hand menu and enter the hostname (and port) from the SSH Access page.
  9. Open the connection. When asked for a username, enter your domain name (for example yourbusiness.co.tz).
  10. Enter your passphrase when prompted. PuTTY hides the characters as you type, so do not worry if nothing appears.

You are now logged in with full access to the SSH area of your site.

Connect via SSH from Linux or macOS (Terminal)

The steps are the same on Linux and on a Mac, using the Terminal app.

  1. Open Terminal.
  2. Generate a key pair by running the command below. When asked where to save the keys, press Enter to accept the default location. When asked for a passphrase you can leave it empty and press Enter, but if you set one, remember it because you will need it when connecting.
ssh-keygen
  1. The command prints where your public key was saved, a file ending in .pub (by default ~/.ssh/id_rsa.pub). Display it with cat:
cat ~/.ssh/id_rsa.pub
  1. Copy the whole key, from start to end, and paste it into the Public Key box on the SSH Access page. Select Add Public Key, then wait for it to be set up (up to 30 minutes).
  2. Back in Terminal, connect using your domain name as the username, followed by the hostname from the SSH Access page:
ssh yourdomain.co.tz@hostname
  1. If you saved your key under a different name or location, point to the private key with the -i option:
ssh -i keyname yourdomain.co.tz@hostname
  1. You will be asked to confirm that you want to connect. Type yes and press Enter.
  2. If you set a passphrase, enter it when prompted. The terminal hides what you type, so do not worry if nothing appears.

Is a port shown on the SSH Access page? If the page lists a port other than 22, add it with the -p option, for example ssh -p 2222 yourdomain.co.tz@hostname. Replace 2222 with the port shown for your package.

You should now be able to connect via SSH to your hosting package.

Need help?

If you also deploy code with Git, read how to use Git version control on your hosting. If you get stuck connecting, contact our support team or see our Web Hosting and VPS Hosting plans.