Skip to content

Back

How to create an SSH key

Applies to:
Professional Hosting
Universal Hosting
WordPress Hosting

Difficulty:
Easy

Time Needed:
5 minutes

Introduction

This is a quick step-by-step walkthrough for creating a private SSH key, which can be used to establish a secure connection when connecting to a server over SSH.

Please note that for Professional Hosting accounts, it is only possible to access SSH with your primary FTP user.


Creating an SSH key on Windows

STEP 1
Open Command Prompt

Firstly you need to open the Command Prompt application.

To do this, use the search field next to the ‘Start’ button (or on older versions click the ‘Start’ button, and choose ‘Run’). Then enter the following command.

cmd

Then hit the Enter key.


STEP 2
Check for existing SSH keys

Before you create an SSH key, its good practise to check if you already have any SSH keys setup on your machine. To do this, simply enter the following command.

cd %userprofile%/.ssh

If you receive the message ‘No such file or directory’, then you have no SSH keys setup on your machine. If this is the case, please skip the next step and go directly to step 4.


STEP 3
Back up existing SSH keys

If you have existing SSH keys, its good practise to back them up before generating a new one.

Firstly, to create a new folder where your back up will be stored, enter the following command.

mkdir key_backup

The copy your existing SSH keys to your backup folder with the following command.

copy id_rsa* key_backup


STEP 4
Generate a new SSH key

Now you are ready to generate a new SSH key. Simply enter the following command to generate your key.

ssh-keygen -t rsa -C "johnsmith@yourdomain.com"

You will then be prompted to choose a location to save your new key. Simply hit the Enter button to accept the location and continue.

Finally, enter and re-enter a passphrase when prompted, and your new SSH key will be generated.


Creating an SSH key on Mac OS X

STEP 1
Open Terminal

Firstly you need to open the Terminal application.

Click the ‘Finder’ icon on your dock, then choose Go > Go to folder…. The enter the following command path.

/Applications/Utilities/Terminal

The double click the Terminal icon to open the application.


STEP 2
Check for existing SSH keys

Before you create an SSH key, its good practise to check if you already have any SSH keys setup on your machine. To do this, simply enter the following command.

cd ~/.ssh

If you receive the message ‘No such file or directory’, then you have no SSH keys setup on your machine. If this is the case, please skip the next step and go directly to step 4.


STEP 3
Back up existing SSH keys

If you have existing SSH keys, its good practise to back them up before generating a new one.

Firstly, to create a new folder where your back up will be stored, enter the following command.

mkdir key_backup

The copy your existing SSH keys to your backup folder with the following command.

cp id_rsa* key_backup


STEP 4
Generate a new SSH key

Now you are ready to generate a new SSH key. Simply enter the following command to generate your key.

ssh-keygen -t rsa -C "johnsmith@yourdomain.com"

You will then be prompted to choose a location to save your new key. Simply hit the Enter button to accept the location and continue.

Finally, enter and re-enter a passphrase when prompted, and your new SSH key will be generated.

Was this article helpful?
YesNo