How Do I Setup a SSH Connection?

Why should I setup a SSH connection?

SSH is a more secure way to connect your server and prevents the connection exposing your servers ports to the Internet. 

How you setup an SSH connection depends on the Operating Systems (OS) used on your local computer and Contabo server. Below you will find guides on how to set up a SSH connection depending on the OS on your local computer and Contabo server.

How do I setup a SSH connection to a Windows Server Using a Windows Local Computer?

  1. In case your local computer runs on Windows, an easy solution is using PuTTY in combination with PuTTYgen.
    Once you install the PuTTY on your machine, you can easily run PuTTYgen. Go to Windows -> Start Menu -> All Programs -> PuTTY -> PuTTYgen
  2. The PuTTY key generator dialog box will appear on your screen:
    Generation ssh keys

    You will find a “Generate” button in that dialog box. Clicking on it will lead to generating the keys for you. We recommend you to set a unique “Key Comment” to be able to identify the Key later.
  3. Now you will need to add a unique key passphrase in the Key passphrase and Confirm passphrase field. It is important that you can remember the passphrase at a later point in time since it is required to load the private key (equal to a password).
  4. Click on the “Save Public Key” and “Save Private Key” buttons to save your public and private keys at safe location.
  5. You will see the text starting with ssh-RSA in the Public key for pasting into OpenSSH authorized keys file field which is located at the top of the window. Copy that entire text to your clipboard by pressing ctrl+c since you need to upload the Public Key to your server.
  6. Connect to your server via SSH.
  7. Check if the directory ~/ssh is already present. If this is not the case, create it by executing the following command:
    mkdir ~/.ssh
  8. Open a text editor like vi to open the text file with:
    vi ~/.ssh/authorized_keys
  9. Paste the public key which you have copied to your clipboard (6) into the file and save the file.
    Now, you can use newly created SSH keys to log in with PuTTY. To set-up your keys in Putty, go to the settings and continue to Connection > SSH > Auth. Notice the last field on the bottom “Private key file for authentication”:
    load your key to PuTTY
  10. Note that in case you’re about to reinstall your operating system using the Customer Control Panel, you can easily set-up the SSH key before installation.    

How do I setup a SSH connection on a Linux server?

  1. Linux servers are by default secured by a password. This type of authentication is not ideal from a security standpoint, and we recommend using SSH key authentication instead. Start by opening the command line on your personal computer.
  2. At this stage, you’re not connected to your server. Run this command:
    ssh-keygen -t rsa
  3. Depending on your version of Linux, your system either automatically creates a new file or asks you to name the new file. Linux will ask you to enter an optional passhrase for additional security. We recommend using this option. Linux will now generate so-called random art picture that looks like:
    SSH key generation
  4. Notice that a pair of keys was generated:
    Your private key has been saved in <FILE_NAME>
    Your public key has been saved in <FILE_NAME>.pub.
  5. Your public key needs to be uploaded to your server while the private key stays on your computer. You can upload the same public key on multiple servers. Let’s move the public key to your server:
  6. In case you already change your port as described in 5.4, use the option -p<YOUR_PORT_NUMBER>:
  7. Now you can connect to your server in a much safer way.
  8. Note that in case you’re about to reinstall your operating system using Customer Control Panel, you can easily set-up the SSH key before installation:
ssh-public key installation

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Modified on 08 Apr 2024

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?