How to Fix the SSH “Permission Denied” Error

SSH is one of the most common methods of connecting to the host. The default root user is usually used to log on to the server when we deploy it. When we tried that we encountered the message that you don’t have permission. We will see in this article how to fix this error quickly.

screenshot 1
SSH Error

Why have we encountered this error?

SSH access for the root user is disabled by default.d. To enable that you need to change the SSH_config file. Why is this option disabled? This option is disabled by default. So that any intruder doesn’t get root access to the server.

Prerequisite to fix the SSH “Permission Denied” Error

  • The physical connection to the server.
  • Bit experience in the Linux terminal
  • Notepad of your choice, Here will use the nano. You can also go with the Vi editor.
  • And most of all patience

How to Fix the SSH “Permission Denied” Error

  • Login to the machine physically.
  • Use the below command to edit the SSH config file.
sudo nano  /etc/ssh/sshd_config
  • Open that file and locate the line “PermitRootLogin” by default this line is commented and access status is prohibited.
screenshot 2
PermitRootLogin Status
  • Remove the # symbol and change the status to yes and save the file.
screenshot 3
PermitRootLogin status after change
  • Restart the ssh service using the below command and check the service status using the below command.
systemctl restart ssh
systemctl Status ssh
  • After that workaround, Try to login into the server using SSH and Voilla as you have access.
screenshot 4
Host login status

Conclusion

You can follow the article for the error. If you encounter any error please let us know in the command will be more than happy to assist you with that.

Leave a Reply

Your email address will not be published. Required fields are marked *