How to use SSH to connect to a Linux terminal on your web hosting service

SSH
(Image credit: Tom's Hardware)

Whether you're trying to run a Bash script, have a look at what processes are running or just move files around, you need to get to the terminal / command prompt on your web hosting plan. Most of the best web hosting plans give you access to the Linux terminal, but require you to use an SSH (Secure Shell) connection to log into it from your PC.

In order to connect from your computer via SSH, you need to first create a public / private key combination and download the private key file. Then you can use both the private key file and a passkey (aka password) in an SSH client such as Putty to establish the connection. Below, we'll show you how it's done.

How to SSH to your web hosting server

Note that these instructions assume that your web hosting plan uses cPanel as its control panel. Some plans use other control panels which will have similar, but not identical interfaces.

1. Navigate to your control panel and log in. Usually, the control panel type is cPanel and the login is at https://www.yoursite.com/cpanel.

2. Click SSH Access.

Click SSH Access

(Image credit: Tom's Hardware)

3. Click Manage SSH Keys.

Manage SSH Keys

(Image credit: Tom's Hardware)

4. Click Generate a New Key.

Click Generate a New Key

(Image credit: Tom's Hardware)

5. Give the key a name ("id_rsa" is usually the default) and enter a password. Then click Generate key.

Click Generate Key

(Image credit: Tom's Hardware)

6. Click Go Back.

Click Go Back

(Image credit: Tom's Hardware)

7. Click Manage next to the Public key.

Click Manage

(Image credit: Tom's Hardware)

8. Click Authorize and then Go Back.

Click Authorize and then Go Back.

(Image credit: Tom's Hardware)

9. Click View/Download next to the private key.

Click View / Download

(Image credit: Tom's Hardware)

10. Click Convert under Convert to PPK format. If it's not automatically filled in, you will need to enter the password you used to create the key.

Click Convert

(Image credit: Tom's Hardware)

11. Click Download Key.

Click Download Key

(Image credit: Tom's Hardware)

A PPK file downloads to your computer. Store it somewhere where you won't lose it.

12. Launch Putty. Download and install it if you don't already have it installed.

13. Enter the hostname and SSH port number. You'll get these from your provider. If you have your own domain the hostname would be your domain name.

Enter hostname

(Image credit: Tom's Hardware)

14. Under Connection->SSH->Credentials, click the Browse button under Private Key file and select the PPK file you downloaded.

select the PPK file

(Image credit: Tom's Hardware)

15. Optional: save your hostname. Under the Session tab, give your session a session name (ex: "mysite") and hit Save. This will allow you to load the hostname and path to the PPK file. So next time you open Putty, you can hit the sitename and hit load.

save settings

(Image credit: Tom's Hardware)

16. Click Open.

click Open

(Image credit: Tom's Hardware)

17. Click Accept if prompted. This happens the first time you log in to a new site.

click Accept

(Image credit: Tom's Hardware)

18. Enter your username and passphrase. The username is the same one you used to log into cPanel, but the passphrase / password should be the one that you used to create the public / private key.

enter username and passphrase

(Image credit: Tom's Hardware)

You should then get the terminal prompt. Save the PPK file because, if you have it, you don't need to recreate it, each time you want to connect, just the first time.

Avram Piltch
Avram Piltch is Tom's Hardware's editor-in-chief. When he's not playing with the latest gadgets at work or putting on VR helmets at trade shows, you'll find him rooting his phone, taking apart his PC or coding plugins. With his technical knowledge and passion for testing, Avram developed many real-world benchmarks, including our laptop battery test.