1. Home
  2. Linux
  3. General
  4. How to Disable SSH Password Authentication on Linux VPS

How to Disable SSH Password Authentication on Linux VPS

How to Disable SSH Password Authentication on Linux VPS
How to Disable SSH Password Authentication on Linux VPS

Introduction

A lot of people use password authentication in order to connect to their servers with SSH command line. However, it is important to note that this authentication method might not be as safe as you might expect it to be; if a hacker succeeds in retrieving your SSH password, every bit of valuable information is at risk, this is why authenticating with SSH keys is the better option.
In this guide, we will show you how to disable password authentication for SSH on Linux VPS.
Check out Our Best VPS  Hosting services ;

  1. VPS Hosting
  2. VPS Management

Prerequisities

For this guide you will require the following things:

  • A working Linux OS based server or VPS
  • Root access to your server or VPS with SSH command line

Step 1 — Configuring SSH Key authentication on your server

Before starting this tutorial, make sure to note that if you aren’t setting up another authentication method before disabling password authentication, you will have a hard time connecting to your server.

Step 2 — Editing SSH configuration file

Continue with this step only if you have completed the previous one and also successfully connected to your VPS. Otherwise; you may end up being locked out of your own server.

  1. Start by connecting to your VPS using the root SSH credentials.
  2. Next, open ‘/etc/ssh/sshd_config’ configuration file using a text editor such as ‘nano’ or ‘vim’ with an SSH command line: ‘nano /etc/ssh/sshd_config’
  3. Once the editor has been opened, you will have to look for a specific line: PasswordAuthentication yes. Nano has a search option which allows you to search for this line at ease by pressing CTRL + W and then typing the keyword ‘PasswordAuthentication’ and clicking ‘Enter’.
  4. This should then point you to the necessary section.
  5. You will now have to change ‘PasswordAuthentication yes’ to ‘PasswordAuthentication no’
  6. To save the changes, exit by pressing Ctrl + X, enter in the letter Y and press ‘Enter’.
  7. Finally, you will have to restart the SSHD service in order for the changes to be applied. Execute the command below.
service sshd restart

SSH password authentication should now be disabled. From this point on, no one is going to be able to access your VPS using the SSH password. Only privileged users who acquire the SSH keys that have been added to the server are going to be able to connect.

Final Thoughts

You should now know how to disable the SSH password authentication on your VPS. A strategy that can help your server to be a lot more secure as since no-one will be able to connect to your server with SSH using a password; only privileged users with SSH or other advanced authentication methods will be able to connect.

Updated on December 24, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']