For Windows OpenSSH, the only available authentication methods are 'password' and 'publickey'. The default is '.ssh/authorizedkeys.ssh/authorizedkeys2'. If the path is not absolute, it is taken relative to user's home directory (or profile image path). Don't use a password. Generate a passphraseless SSH key and push it to your VM. If you already have an SSH key, you can skip this step Just hit Enter for the key and both passphrases.
Some server providers, such as Amazon EC2 and Google Compute Engine, disable SSH password authentication by default. That is, you can only log in over SSH using public key authentication.
SFTP is a protocol that runs over SSH, so this means SFTP using passwords will not work by default when SSH password authentication is disabled.

To enable SSH password authentication, you must SSH in as root to edit this file:
Then, change the line
to
After making that change, restart the SSH service by running the following command as root:
Enable Logging In as root
Some providers also disable the ability to SSH in directly as root. In those cases, they created a different user for you that has sudo privileges (often named ubuntu). With that user, you can get a root shell by running the command:
If you instead want to be able to directly SSH in as root, again edit this file:
And change the line
to

After making that change, restart the SSH service by running the following command as root:
If you enable this setting, don't forget to set a strong password for root by running the command.
One of the basic SSH hardening step is to disable password based SSH login.

You know that you can use ssh with the root or other account’s password to login remotely into a Linux server.
But this poses a security risk because a huge numbers of bots are always trying to login to your system with random passwords. This is called brute force attack.
You don’t believe me? You can check the logins on your Linux server. You’ll be surprised to see so many failed attempts on your server.
This is why you should use a strong password. The proper way to deal with them is to use a tool like fail2ban. Another way is to disable password based authentication so that no one can connect via login password.
In this way, only those systems that have their public ssh keys added to the server (called key-based authentication) will be able to connect to server. Read about setting up ssh configuration.
Disable SSH password authentication
Before you do that, you must keep the following things in mind:
Ssh Auto Password
- Make sure to create your ssh key-pair on your personal/work computer and add this public SSH key to the server so that at least you can login to the server.
- Disabling password based authentication means you cannot ssh into your server from random computers.
- You must not lose your ssh keys. If you format your personal computer and lose the ssh keys, you’ll never be able to access the server.
- If you are locked out, you will not be able to access your server ever.
Some cloud server providers like Linode and UpCloud provide VNC console that could still help you.
Only disable password based SSH authentication if you are familiar with SSH and other sysadmin concepts. You should also know how to use a terminal based text editor like Vim or Nano.
Okay. So now you know the risks associated with disabling SSH logins via password. Let’s see how to do it.
Login as root to your Linux server using key based authentication. Use an editor like Nano or Vim to edit the following file:
Find the following line:
Ssh Password File
And change it to:
If there is a # (means commented out) at the beginning of that line, remove it.
Save the file after making these changes and restart the SSH service using this command:
That’s it. You have successfully disabled password based authentication in SSH.
Questions and suggestions are always welcome.
Become a Member for FREE
Join the conversation.
