SSH server in most systems is by default configured to allow public-key authentication. The method will enable you to use your public and private key pair to log in to an SSH server without using a username.
When you are using public-key authentication in your server, then you can't ssh from another server to your server .When you try to ssh from another server It shows like this:-
Steps to disable public key authentication in SSH:
1.Login to your server via ssh.
2.Open SSHd configuration file with any editor.
-
$ sudo vi /etc/ssh/sshd_config
3.Then search for PubkeyAuthentication and set the option to yes(for enabling public key authentication) or no(to disable public key authentication).in Vi editor for searching the word "PubkeyAuthentication" enter "/" and type PubkeyAuthentication . Or in nano editor CTRL+w.
-
PubkeyAuthentication
no
.
4.Then Enable Password Authentication. For enabling password authentication search the word PasswordAuthentication
then remove # on this line
-
PasswordAuthentication
yes
.
And also comment (put #) on line
-
PasswordAuthentication
no
.
5. And also search the word ChallengeResponseAuthentication and disable it by adding no
.
6. Then save and exit the editor.
7.Then restart ssh service by the following command
-
sudo systemctl restart sshd
8. Now you have successfully disabled public-key authentication.