> For the complete documentation index, see [llms.txt](https://spacecore.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spacecore.gitbook.io/wiki/en/os-and-software/disabling-password-access-to-linux.md).

# Disabling access to Linux using a password

{% hint style="danger" %}

### This content is outdated

**The knowledge base has moved →** [**https://wiki.spacecore.pro/**](https://wiki.spacecore.pro/)

This wiki is no longer updated. All current guides and articles are at the new address.
{% endhint %}

{% content-ref url="<https://wiki.spacecore.pro/>" %}
<https://wiki.spacecore.pro/>
{% endcontent-ref %}

***

If you are using SSH keys, disabling access to the server via password will be a useful additional security measure for you.

## Switching off via nano

Use the following command:

```
nano /etc/ssh/sshd_config
```

We get into the **sshd** config.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FBY0jMQqs3L4xIFt2gLPB%2Fimage.png?alt=media&amp;token=4399aa58-d972-4cb7-abad-9d7a81c3a9d1" alt=""><figcaption></figcaption></figure>

We find the string **PasswordAuthentication yes**

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FMJrIc2PHUlVCAs0tKbwn%2Fimage.png?alt=media&amp;token=3f668ee6-06d1-4f0b-857c-49bc1b493655" alt=""><figcaption></figcaption></figure>

We need to remove the grid (**#**) so that the row becomes active. And then we change the value of **yes** to **no.**

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FZYFzsxVIUuAZ7CRt7tnz%2Fimage.png?alt=media&amp;token=090a7958-6974-4b5d-bb99-37bcc48e74c1" alt=""><figcaption></figcaption></figure>

Press **Ctrl + X**, enter **Y** to save.

Restarting the **SSH** service:

```
sudo service ssh restart
```

## Disconnection via sFTP

In the panel above the file manager, we need to erase the standard path **/root** and specify **/etc/ssh**

In this directory, we need to open the **sshd\_config** file.

We find the corresponding **PasswordAuthentication yes** string.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FzX7T3byterXetbjCTTcl%2Fimage.png?alt=media&amp;token=3752ea89-9d4d-4f79-baa8-8b1a01a99d09" alt=""><figcaption></figcaption></figure>

Remove the grid (**#**) so that the line becomes active. And then we change the value of **yes** to **no**.

<figure><img src="https://287241268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyXvdNIxNLIOcexv7AfU2%2Fuploads%2FdgXPVyEpFBpgtQFb83Eg%2Fimage.png?alt=media&amp;token=cf3c4a44-f6e8-4802-8c84-37a774ea59d6" alt=""><figcaption></figcaption></figure>

We save the file and send it to the server.

## Restarting the SSH service:

```
sudo service ssh restart
```

## Using an SSH key in sFTP

After enabling access only via **SSH key**, a problem may arise when connecting via **sFTP**, which is extremely simple to solve at the moment.

### FileZilla

Click on the Edit category and select Settings

Then select the **sFTP** page and click the Add **Key File** button.

Select the location and add the file.

The key has been added, now **FileZilla** will take it into account when trying to connect to servers.

### WinSCP

Click on the button to create a new connection:

A window opens. Here we specify the **IP address** of the server and the **Username**.

Use the More button under the Password line.

In the window that opens, select the **Authentication** section.

Add the **private key** and click **OK**.

We are trying to connect to the server.

The program requests the secret key code, we enter spacecore:

We have connected to the server!
