Knowledgebase: Site Functions
Generate SSH Keys and Connect to Your Account via PuTTY (Windows)
Posted by on 07 February 2014 12:57 PM

Note: you do NOT need to generate/use keys to access your account via SSH.

This tutorial will show you how to generate a public/private SSH key pair on a Windows operation system using PuTTYgen (PuTTY Key Generator) and then install it on your Cirtex Hosting account. This allows you to use SSH keys for authenticating!

To get started:

  1. Download the PuTTY installer
  2. Once the download is all finished, go ahead and launch the installer and follow the on-screen instructions to install PuTTY
  3. The default location is fine but we recommend selecting the following options when you get to the Select Additional Tasks screen:
    • Create a desktop icon for PuTTY
    • Create a Quick Launch icon for PuTTY (current user)
    • Associate .PPK rules (PuTTY Private Key) with Pageant and PuTTYgen

      Setup PuTTY
  4. Launch PuTTYGen (in your Start Menu under ‘PuTTY’)
  5. When PuTTYGen launches keep all of the default settings (listed below):
    • Type of key to generate: SSH-2 RSA
    • Number of bits in a generated key: 2048

      PuTTY Key Generator
  6. Click the Generate button to create your key pair (move your mouse around within the blank space during the process)

    Click Generate

    Once the generator is complete, you will see a window with your new public key and key fingerprint.

    PuTTY Key Generator

  7. Change the ‘Key comment’ to anything you would like (maybe the workstation name, for easy identification: ‘my-workstation-home’)
  8. Fill in the Key passphrase and the Confirm passphrase text fields

    Note: these are important, make sure you set a passphrase! Make sure it’s a secure passphrase and isn’t easily guessable or is used elsewhere.

  9. Select and copy (CTRL + C) the contents of the public key located in that large text field and copy the entire contents (control + C) into your clipboard

    Do not quit PuTTYGen. Your public key will look similar to the below:

    ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAgIXR9GaGgkaX99NDEeGZqELW9xRkwJc9+BH679FNL//BKSF8k/zGRuWP4ab9Zy0eSlqOVMS5PUeHIhiaddym6MHaBRf9GXxvMOUdVsNh7Eff1S9y3NVcDGhvKaXOmhNHZEWNh0sED+q8oX6lmyzCF92xn+XeCbxrGRetoGSzlyjtl0BDudHME3CyX4VpSkk2wJ8X/IPHFiqvaTyuVIss0n9xrsbN1RmrwrmmSQ+DKA5VBbbpBqI6y87RBW2x1W6IOaaM5izSa5EBjS6ixwjf2Qs9Aj2O93YhQxjUMOeFmpdSI1ZP68pnIcJf9iOv/7zTWy8GwwctCJjCbi94odY3iQ== my-worsktation-key 
     
  10. Open Notepad (or similar text editor), paste (CTRL + V) the contents you just copied into your new text editor file and save it as a .txt file

    The public key will be applied to your Cirtex Hosting account later.

    PuTTY Key Generator
  11. Go back to PuttyGen and click the ‘Save private key’ button on the main window under the ‘Save the generated key’ section
    Note: you can call that file ‘privatekey’ or ‘privatekey.ppk’ — make sure to save it somewhere you will be able to find it easily.

    The private key stays private and should never be given to anyone. It does not go on your Cirtex Hosting account; it stays on your workstation. Keep this file safe! If you lose your private key you’ll need to redo this entire process.
  12. Quit PuTTYGen

 

Now, we're gonna log in to your Cirtex Hosting account via SSH so you can install your public key.

  1. Launch PuTTY
  2. In the Category section on the left, scroll down and under Connection > SSH, select the ‘Auth’ option
  3. Where it says ‘Private key file for authentication:’ click the Browse button

    PuTTY Configuration
  4. Find the private key you generated previously and click the Open button to load it

    The text field should now be filled in with the path to your private key.

  5. Click Session, in the Category section, and fill in the ‘Host Name’ field with your account hostname (your account domain or IP address will also work)

    PuTTY Configuration

    Tip! You can save this profile for later, to help eliminate some of the work, by typing a name for the session in the Saved Sessions text field. Then, click the Save button. The sessions will be saved and will show where Default Settings currently shows. When you connect to the server next time simply select the session you created and click the Load button. Click the Open button at the bottom to load up that saved session!
  6. Click the Open button and enter your Cirtex Hosting account username and password when prompted

    You’re logged into SSH!

  7. Type the following command at the prompt (and press Enter when you’re done):

    mkdir ~/.ssh; touch ~/.ssh/authorized_keys; chmod 700 ~/.ssh
  8. That command will create a new SSH directory and a new blank file where you can put your public key and any additional public keys needed to access your account

    Note: all keys need to be on separate lines in the file.
  9. Open the ‘authorized_keys’ file in your favorite command line text editor (vi/nano/emacs)
    Note: for the sake of this example we are using nano.

    nano ~/.ssh/authorized_keys

  10. Once you have made the changes exit your text editor, making sure to confirm the overwrite/filename if necessary
  11. Go to your workstation and locate the public key you generated earlier in PuTTYGen (make sure you’re nabbing the public key, not the private key!)
  12. Copy and paste the contents of the public key into the ‘authorized_keys’ file on your Cirtex Hosting server; it should paste as a single line
  13. Save the file and exist PuTTY
  14. Re-open PuTTY and make a new connection to your Cirtex Hosting account like you did previously, and make sure to load your saved session like instructed
  15. Enter your login name and SSH key passphrase when prompted and then hit Enter

    The output should look something like:

    Authenticating with public key "my-workstation-home"
    Passphrase for key "my-workstation-home":

You’re logged into your account via SSH!

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion