SSH Using Keys

You can access your Linux server using SSH (Secure Shell).
SSH is a text based interface to your server where you can execute commands to perform things like restarting your web server or your email server or to discover how many emails are in the queue.

Free SSH clients are available online.
A popular one is PuTTY available here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

The documentation for PuTTY is available here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html

Our Knowledgebase Videos are available here:
https://support.cwcs.co.uk/index.php?/Knowledgebase/List/Index/23/linux-ssh--putty


SSH Keys

You can heighten your server's security by using SSH Keys instead of passwords to access your server.
These instructions are for PuTTY users on a MS Windows platform.
Download and install putty.exe, puttygen.exe and pageant.exe from the PuTTY download page:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Generate Keys

Use PuTTYgen to create a private/public key pair.
 Simply launch puttygen.exe (by double-clicking on it). Make sure that the type of key to be generated is "SSH-2 RSA" and press "Generate".


Launch Puttygen

You will need to move your mouse around to generate enough randomness for the program to create your keys.

Generate Key Pair

Create a comment and password and save your public and private keys.
Copy the Public Key from the PuTTY Key Generator - highlight, right-click and "copy".

Copy Public Key


Log Into Your Server

Launch putty by double-clicking on putty.exe.

Launch PuTTY

Enter the Host Name or IP address in the top text box.
This will be something like 192.168.0.2 or www.yourdomainname.com.
In the "Saved Sessions" text box below enter the name you wish to call your server, such as "My Server".
Click "Save".

PuTTY Saved Session

Click "Open"
Click "OK" at the warning which pops up. This appears because you've never logged in before.
Enter your username and password. (This information is available in your Welcome Email).

PuTTY Login


Copy Public Key To Server

Log into your server using SSH and copy your public key into your ~/ssh/authorized_keys file.

 Type this into your putty window:

 nano ~/ssh/authorized_keys

Right-click to paste the public key.
 Press the "Control" key and "x" at the same time - Ctrl-x
 
 OR
 Type this into your putty window:

cat >> ~/ssh/authorized_keys

Right-click to paste the public key.
 Press the "Control" key and "D" at the same time - Ctrl-d
 
 
 Launch Pageant
 
 Pageant will store your keys and use them to automatically log into your server(s).
 http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter9.html
 Simply double-click on pageant.exe.
 This will put an icon into your task bar.
 Click on the icon and press "Add Key".
 <img src="images/pageant1.png" alt="Pageant Add Key" />
 Find the Private Key you created earlier and enter your passphrase when promted.
 
 If you make sure that pageant is running with your keys loaded you'll be able to log onto your server(s) without having to enter a password.
 
 Once you're happy with this you can take steps to remove the ability to log in with a password.
 This will prevent hackers from brute-forcing your ssh login password.
 Please contact CWCS Support if you wish to remove the ability to log into your server using a password.