How Do I Setup a SSH Connection?
Why should I setup a SSH connection?
SSH is a more secure way to connect to your server and prevents the connection from exposing your server's ports to the Internet.
How to set up an SSH connection depends on the operating systems (OS) used on your local computer and the Contabo server. Below you will find instructions on how to set up an SSH connection depending on the OS used on your local computer and Contabo server.
How do I setup a SSH connection to a Windows Server Using a Windows Local Computer?
- 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 - The PuTTY key generator dialog box will appear on your screen:
In this dialog box you will find a "Generate" button. Clicking it will cause the keys to be generated for you. We recommend that you set a unique "Key Comment" to be able to identify the key later. - Now you need to add a unique key passphrase to the Key passphrase and Confirm passphrase fields.
It is important that you remember the passphrase because it will be used to load the private key (equivalent to a password). - Click on the “Save Public Key” and “Save Private Key” buttons to save your public and private keys to a secure location.
- 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 all of this text to your clipboard using ctrl+c, as you will need to upload the public key to your server. - Connect to your server via SSH.
- Check if the directory ~/ssh is already present. If this is not the case, create it by executing the following command:
mkdir ~/.ssh
- Open a text editor like vi to open the text file with:
vi ~/.ssh/authorized_keys
- Paste the public key which you have copied to your clipboard into the file, then 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”: - 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?
- Linux servers are password-protected by default. 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.
- At this stage, you’re not connected to your server. Run this command:
ssh-keygen -t rsa
- Depending on your version of Linux, your system will either automatically create a new file or prompt you for a name. Linux will ask you to enter an optional pass phrase for added security.
We recommend that you use this option. Linux will now generate a random art picture that looks like this: - 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. - 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:ssh-copy-id<YOUR_USERNAME>@<YOUR_IP>
- In case you already change your port as described in 5.4, use the option -p<YOUR_PORT_NUMBER>:
ssh-copy-id -p<YOUR_PORT_NUMBER><YOUR_USERNAME>@<YOUR_IP>
- Now you can connect to your server in a much safer way.
- 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](https://s3-eu-central-1.amazonaws.com/euc-cdn.freshdesk.com/data/helpdesk/attachments/production/103082482812/original/Topi-ga8aVuVoG1sNFcVGTSqzYVSs8zWxQ.png?1706179625)
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article