# Connecting via SSH keys

Are you concerned about the security of your server? You need to activate the authorization method via SSH key and now more!

## Windows installation

Launch the **PuTTYgen** app, or you can download the portable version for its system clearances by one of the links:

{% hint style="info" %}
**32-bit** version: [download](https://mirror.spacecore.info/uploads/puttygen\(32bit\).exe)

**64-bit** version: [download](https://mirror.spacecore.info/uploads/puttygen\(64bit\).exe)
{% endhint %}

At startup we have this window:

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FXfkXBTGzn8XNLpzSnJrj%2Fimage.png?alt=media&#x26;token=91eb25e3-f13b-46d1-a2e6-b6749c3f093f" alt=""><figcaption></figcaption></figure>

Press the **Generate** button and for some time lead to random places with the mouse pointer, it is necessary for the unique generation of the key.

After the action we see the following data:

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FSwLvzWnu3jRQjwFzgcny%2Fimage.png?alt=media&#x26;token=28372315-d69f-4df1-a498-f80b21ee3153" alt=""><figcaption></figcaption></figure>

The **Public key for pasting** line contains prepared text that we need to use later.

At the request of the **Key passphrase** You can specify additional code for your key, which will need to be entered at each connection to the server, we will specify the word spacecore. Then you need to click the Save **public key** button to additionally save the **public key** that was specified above. And press Save private key and save the **private key** file that we need to connect to the server.

{% hint style="warning" %}
The name of the key files can be any, it does not affect anything.
{% endhint %}

We saved and received 2 files:

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FBwegKyWHrDkGHoxc0giZ%2Fimage.png?alt=media&#x26;token=c413fafe-c6b7-4a4e-b072-5f85c154f9ec" alt=""><figcaption></figcaption></figure>

## There are two ways to fix the SSH key on the server:

### Using nano utilities

After connecting to the server we need to use the command

```
nano /root/.ssh/authorized_keys
```

We have entered the editing panel of the **authorized\_keys** file, which is responsible for configuring the **SSH keys**.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FjKW3a9GPwA9Lj5KufH0e%2Fimage.png?alt=media&#x26;token=2d704904-6c03-4d53-ac95-cfc5a62cf0bc" alt=""><figcaption></figcaption></figure>

At the moment the file is empty, we need to fully copy all the text from the window to **PuTTYgen:**

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FeHrenXWpHUXHuBJaNh6b%2Fimage.png?alt=media&#x26;token=23f572f9-c1ba-4985-b693-c29826c861dd" alt=""><figcaption></figcaption></figure>

Then insert it into the editable PKM file (right mouse button).

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FI8bmI2Dc9NB8lz2cM821%2Fimage.png?alt=media&#x26;token=5d1b3945-e3b9-46bb-89c8-1ddad6b97ed4" alt=""><figcaption></figcaption></figure>

Press the key combination **Ctrl + X**

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fh1fVF2NXSTgfXNzCRjqS%2Fimage.png?alt=media&#x26;token=ab2ceef2-0c5b-4add-af69-857aa6eb1bc5" alt=""><figcaption></figcaption></figure>

Confirm file saving by entering the letter **Y.**

The **SSH key** was successfully linked to our server.

### Data transmission via **sFTP**

Connect to our server and see on the main page the list of files, go to the directory . **ssh**

Here we see the file **authorized\_keys**, currently it is empty, its size is 0 bytes.

Press **PKM** and open file

Here we insert the same **PuTTYgen** public key.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Feex3NZmmSylPOKPtYNYq%2Fimage.png?alt=media&#x26;token=4700039d-4d61-46c1-8f97-dd6ea80ac788" alt=""><figcaption></figcaption></figure>

Save the changes and send the file to the server.

Done, **SSH key** set!

## Connecting via SSH key

When we open **PuTTY** program we enter the standard interface, we need to enter the **IP address** of the server.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FwQ3I3BygvBCMaw1RyRgd%2Fimage.png?alt=media&#x26;token=b1e2871e-e392-4612-a88f-5cc224a76165" alt=""><figcaption></figcaption></figure>

In the left menu, open the **SSH** tab and move to **Auth**.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FFOtLQHKn486OEeGYWCjj%2Fimage.png?alt=media&#x26;token=5f26d405-e6c3-4305-94ca-62c7137d32ee" alt=""><figcaption></figcaption></figure>

Here we need to select the location of the **private key** file (note, not public!) with the extension **. ppk**

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FqgSBSAcYPFeIJLCO9riP%2Fimage.png?alt=media&#x26;token=b4ce06b9-5a7b-4246-a6d7-9efc505a2d6d" alt=""><figcaption></figcaption></figure>

After adding the key, press the **Open** button. The standard **login** interface appears, fill in.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FeI3kAAclgQ3SDTfTYPhV%2Fimage.png?alt=media&#x26;token=afc05e98-3d43-4bfb-8bf6-2d6ff9364de2" alt=""><figcaption></figcaption></figure>

After entering the username, we ask for the **Passphrase-code** (when generating the key we specified **spacecore**), enter.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2F495ZWS42QPVVVNEDfeLr%2Fimage.png?alt=media&#x26;token=bcb98faf-bf43-4e25-9c59-baa32d1f5173" alt=""><figcaption></figcaption></figure>

Congratulations, **SSH key** authentication was successful!

## How do I save server data for quick login?

You need to enter the IP address of the server as well as bind your **private SSH key**. Then we specify the name of the session to be saved.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fqr10HtqU2oOw4qnsdzLa%2Fimage.png?alt=media&#x26;token=4c25348d-d8fb-4958-b0df-274f683fb50a" alt=""><figcaption></figcaption></figure>

Session remained.

***

You can also specify a *user name* in front of the **IP address** to speed up the login process, like this:

{% hint style="warning" %}
**username\@IP-address**
{% endhint %}

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2F9JeIf0tlpcqyoinoRGzH%2Fimage.png?alt=media&#x26;token=e8c061ef-21b0-4043-893e-243f306d86ef" alt=""><figcaption></figcaption></figure>

Keep. Now, double-clicking the saved session will open a window in which we should enter the **private key** code (only if you have specified it. In the absence of the code, the connection will be instantly without entering additional data).

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FvZLC7lma4JNyyqQX2jfA%2Fimage.png?alt=media&#x26;token=1b4bfc29-59e7-4bb8-b9ee-ebee0fdf625e" alt=""><figcaption></figcaption></figure>

We introduce it. That's it, we're connected!

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2Fpj0Wdc69TuK481zAjccw%2Fimage.png?alt=media&#x26;token=b1c5a50b-5d66-4e51-84b6-60c9d536e5da" alt=""><figcaption></figcaption></figure>
