# Disabling access to Linux using a password

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="/files/o8mUmPOcufmqrlD12R0X" alt=""><figcaption></figcaption></figure>

We find the string **PasswordAuthentication yes**

<figure><img src="/files/h9GRE6a69iOsra8ThCl5" 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="/files/uPSUeUImHnRhDqARUgsv" 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="/files/0b9AOFJLvbFy2YgNy6YA" 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="/files/9kKJqPd5jyX3H41I0nFd" 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!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spacecore.gitbook.io/wiki/en/os-and-software/disabling-password-access-to-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
