> For the complete documentation index, see [llms.txt](https://prime-stake-pool.gitbook.io/node-setup-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prime-stake-pool.gitbook.io/node-setup-guide/server-setup-basics/how-to-setup-your-cloud-server-securely/disable-root-login-password-and-change-default-port-22.md).

# Disable root login,password and change default port 22

Security Layer 3 & 4

Now let us disable root login and password. For this first go to folder 'ssh' then edit file 'sshd\_config'

```
cd /etc/ssh 
```

```
sudo nano sshd_config 
```

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2Fs974szFypDXAoMlHCGlh%2Fp26p.png?alt=media&amp;token=45c2ee92-69c9-4d1b-a949-3017683e7cca" alt=""><figcaption></figcaption></figure>

Here we will change the following parameters:

1\) port 22

2\) PermitRootLogin yes

3\) PasswordAuthentication yes

Remember to remove the hash sign before each parameters to take effect.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2Frv8s3qVKVoNIQU06bmWb%2Fp27p.png?alt=media&amp;token=4ecdc902-f0c3-47e8-98b5-fec694861543" alt=""><figcaption></figcaption></figure>

First change the 'PermitRootLogin yes' to 'PermitRootLogin no'.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FQs63VpDZgMR7TsIijE4x%2Fp28p.png?alt=media&amp;token=fc9877f1-55f4-4146-b72e-77e63f1e88ff" alt=""><figcaption></figcaption></figure>

Then add a line just below it 'AllowUsers rocket'. You can add as many users you want. Just give a space between each users.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FcgXrw0Gon51Mv5hMuiOC%2Fp29p.png?alt=media&amp;token=e573afc9-3640-48c2-93e7-9d49bc456e2f" alt=""><figcaption></figcaption></figure>

Now change the 'PasswordAuthentication yes' to 'PasswordAuthentication no'.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FrEfSxcGam3TPZetp8blE%2Fp30p.png?alt=media&amp;token=54d04bb1-0a88-4b5f-a917-6b4a1609428e" alt=""><figcaption></figcaption></figure>

Change the default port 22 through which ssh connection has been made to some other port in the range 1024 - 32767. Here we choose our Port as 1234. Then use (^O) to write out/ save the parameters and then (^X) to exit.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2F3SkpW3M7YOt13wJpZS0L%2Fp31p.png?alt=media&amp;token=4de1a206-9ece-44f7-af4f-b9aa353ee2b1" alt=""><figcaption></figcaption></figure>

Then you must restart the service for the change in parameters to take effect.

```
sudo systemctl restart ssh 
```

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FbQiMsAAgNOIIad4z2zPY%2Fp32p.png?alt=media&amp;token=eebc76c0-7c35-4247-8239-e8cc0156102a" alt=""><figcaption></figcaption></figure>

Now check the status with the command:

```
sudo systemctl status ssh 
```

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FSxjpyxmc3Ad4aCO3P5Qy%2Fp33p.png?alt=media&amp;token=3a772015-9e5a-4979-a9a8-982cb77acb3c" alt=""><figcaption></figcaption></figure>

It may take some time to show the updated status. Note over here that the server is now listening to port 1234.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2Fv249WhXvqYrQa3Fr4Mi7%2Fp34p.png?alt=media&amp;token=9186a807-8e87-4f7a-9a25-16c74beef6d9" alt=""><figcaption></figcaption></figure>

Now if you try to connect with 'root' as user it won't work, as it is disabled. So from now on we connect user as 'rocket' with the command:

```
ssh rocket@5.189.149.230 -p 1234 
```

Here we put '-p 1234' at the end of the command as the default port 22 has been changed.

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FMIJ4gwTRLNszQHBs0mvQ%2Fp35p.png?alt=media&amp;token=dbe5a60c-d793-47ae-b6bd-abc6453f7b68" alt=""><figcaption></figcaption></figure>

So we have covered up to four security layers in setting up your server:

1\) Create new user

2\) Disable root login

3\) Change default port 22

4\) Use SSH key pair to access your server

Now we will proceed with the remaining three security layers:

5\) Install fail2ban

6\) Use hardware key authentication as an additional layer of security

7\) Firewall Settings

<figure><img src="https://1333520747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjnxYeTEvdhQuzHnaDHIu%2Fuploads%2FfyO9BFnyI1DgMFtq7JUV%2Fp36.png?alt=media&amp;token=85d3e8b2-d7bc-4477-8e7c-99906abc89db" alt=""><figcaption></figcaption></figure>
