loader
image/svg+xml
  • Data centers and network
  • Products and services
  • Industries
  • Support
  • News
  • About us

Knowledge Base

How to create and access a Linux-based cloud server via an SSH key

To access Linux-based server via an SSH-key, it is necessary to generate a key pair. The private part of the key is stored on the PC from which you connect, and the public part is placed on the Cloud Server. You can generate the key pair on your PC, place the public part in the control panel and use this key in the future. You can also generate a key at portal.servers.com. In this case, you will be given a private part of the key that is to save on your PC. Both options are considered below.

1. Creating a key pair in OS

1.1. Guide for Windows users

Download Putty SSH-client and a private keys (PuttyGen) generator:

Start PuttyGen. Select SSH-2 RSA, click Generate Key Pair, move the mouse until the progress bar is full.

Enter and confirm password. Save the key files in a safe place.

Select and copy the text of the public key as indicated in the picture. For more information about how to add this key via your account at portal.servers.com, see Adding the previously created key to portal.servers.com

1.2. Guide for Mac OS and Linux users

To generate an ssh-rsa keychain, open the Terminal. Run the following command:

ssh-keygen -t rsa -b 4096

Specify the path where you want to save your private ssh-key. For example:

/home/youruser/.ssh/rsa_key

Then enter and confirm your password. While entering it you will not be able to see the characters and that is okay:

Enter passphrase (empty for no passphrase): Enter same passphrase again:

You should get a result similar to the one below:

Your identification has been saved in /home/youruser/.ssh/rsa_key Your public key has been saved in /home/youruser/.ssh/rsa_key.pub

The private key file rsa_key must be stored on your local computer.

To see the contents of your public key, run the following command:

cat /home/youruser/.ssh/rsa_key.pub

A text, similar to the one below, will appear on your screen:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDocpVowN3FdhvKG9hKAILZLo3lMzvP6jBs+ZCAgyDXHypre3V9BFb1ywUesQ6bfi2FOQDK1I15Ed47sW/ZYAMn5Bo9+RRYoilPo6Wu8S4GQd+g4uGeV6LxX5H7YdJkyb7ZdQ6ItjEvLNtK6Qg2×83DMyMZv0cD3RtLJmJJLyR6EwGtKGy3JW4ojmRlx15nswF4qSulY722TGIXZc5l2xZzS27wvi3Nfm51EQ0eyFDQYuAkFQm5HUlZPEeBXoO75P6gOXe2NOQ514HGpc/UOtgnr+YV5KdOjN2CmqVHljC0mYLl3TZRxVhrMp46UiuAm04GWaocE/4DQRQoSQtn45lwN1/FJXYBjQhh99m98u8i4k4RQ05L6X+iMof2KXylOwaFiv7LTuXVP8dGGnHfWhHanhR23fb7yGcwvIIuEb1z0qvCh8NlQkXBL0ppgb3oPrrJaZGqULI4KJ8Hrb0Xf1B48VlcC0JmR3hRPU1dLl2XQuFn1KFnEeONp9UTgMEyOfDKXjq8XZu1arbFuhZENfDpVy5J+i9RifmACE8wadgXb7ACKrycLV6JButnhARWyPawPqUD8ZfRSrjaxjveHv0JfcaySmNpgToC2ZeG7/YurKS9gF64stUQOjXO5rfl8nZUEgrSo07lDjz+r2lobi0CmtdbsEXqCuKYjIZBJ8/arw==

Copy and paste this text for the next step.

For more information on how to add this key via your account at portal.servers.com, see Adding the previously created key to portal.servers.com

2. Adding the previously created key to portal.servers.com

Log in to your account at portal.servers.com.

Go to Profile → SSH-keys.

In the upper right corner click on the «Add SSH-key» button.

Next, enter any name for your public key, tick the option «Use public SSH-key», insert the text of your public key in the next window and click «Add».

3. Creating a new key in your personal account

Log in to your account at portal.servers.com.

Go to Profile → SSH-keys.

In the upper right corner click on the «Add SSH-key» button.

Next, enter any name for your key, tick the option «Generate new keypair», and click «Generate».

In the new window, copy the private key and store it on your PC in a safe place. You will need this key to connect to the Cloud Server in the future. Click «Close window».

4. Creating a Linux-based Cloud Server with SSH-key access

Go to Cloud Servers → Create & Manage.

Click «Create virtual machine».

Enter the name of your virtual machine, choose the region, choose the appropriate Linux distribution and the necessary configuration in the window «Authentication method», select «SSH key», select the previously created SSH-key in the window «Administrator SSH-key» and click «Create VM» at the bottom of the page.

5. Connecting to a Linux-based Cloud Server with SSH-key access

5.1. Guide for Windows users

Open Putty SSH-client. Go to Connection → SSH → Auth and select your private key file.

Next go to Connection → Data. In the text box «Auto-login username» enter «cloud-user» (be careful, usernames for Linux OS are case sensitive).

Go to the Session tab. In the Host Name text box, enter the External IP of your virtual machine. Select Port 22, which is the default port for SSH.

Enter the session name and click «Save». This is required to ease the use in the future. To connect to your Cloud server, click the «Open» button.

Enter the password for your key.

To get root user privileges, type:

sudo su -

5.2. Guide for MacOS and Linux users

To connect via your local computer that is running MacOS or Linux, you need to open the Terminal and enter the following command:

ssh cloud-user@external_ip_of_machine -i /home/youruser/.ssh/rsa_key

Replace external_ip_of_machine with the external IP of your Cloud Server.

Replace /home/youruser/.ssh/rsa_key with the path to the private key.

To obtain root user privileges, type:

sudo su -