Linux Commands

How to Fi SSH Permission Denied

How to Fix ssh Permission Denied

Working with SSH is time-saving and secure but can get frustrating when you get the ssh permission denied error and can’t figure out what is causing the error.

With ssh, you can easily login into your remote server and perform all activities, including installing software and working with files.

If you’ve installed SSH on your client and server but still have issues accessing the server, the problems result from the configurations in most cases. Few rules need to be in check for the smooth running of SSH. This guide covers how you can easily fix the SSH error in several ways.

What Is SSH?

Secure Shell (SSH) is a protocol that allows a client machine to connect to a Linux server remotely and securely using a text-based interface. Upon a successful connection, a shell session will open from where you can work with your server.

What Causes the ssh Permission Denied Error?

The common reasons include:

  • Incorrect SSH public key contained in the authorized_keys file
  • Incorrect file permissions
  • Misconfiguration in the SSH server config file

Fixing the error is straightforward and we will consider various methods you can use.

How to Resolve the SSH Permission Denied Error

If you get an error like the one below, we have a solution for it.

Solution 1: Enable Password Authentication

You first need to check the PasswordAuthentication and ensure it is enabled.

You need to open the sshd_config file on your server using an editor. In our case, we are using nano editor and the command would be:

$ sudo nano /etc/ssh/sshd_config

Once opened, locate the PasswordAuthentication line and ensure it is set to end with yes.

Also, below the PasswordAuthentication, ensure the ChallengeResponseAuthentication is disabled and ends with a no.

Once you make the changes, save your file and exit. You must restart the ssh service using the command below.

$ sudo systemctl restart sshd.service

Next, proceed to try the connection again.

If the solution doesn’t work for you, try the others below.

Solution 2. Check Other Configurations

Your sshd_configuration file determines if the ssh connection goes through or not. Therefore, everything needs to be checked to fix the ssh permission denied error. For this solution, you must locate various lines and ensure they match the ones listed below.

First, open the configuration file as we did before.

$ sudo nano /etc/ssh/sshd_config

Once opened, locate and edit the lines below to ensure they match. Most of them are commented but you can un-comment them by deleting the # before them. From there, you can edit and align them to match the ones below.

PermitRootLogin no

PubkeyAuthentication yes

UsePAM yes

Finally, save and exit the file. Then, restart sshd

$ sudo systemctl restart sshd.service

Your ssh connection should now successfully log in to the server.

Solution 3. Change File Permissions

The owner permissions of your home directory should be set to read, write, and execute. You can verify so using the command below.

$ ls -ld

If not set to drwx——, set them using the chmod command.

$ chmod 0700 /home/your-username

Also, the owner permissions for the authorized_keys in the .ssh directory should be set to read and write.

Verify so using the command below.

$ ls -ld authorized_keys

If not properly set, use the command below.

$ chmod 0600 /home/your-username/ .ssh/authorized_keys

Once you restart sshd, your ssh will start connecting normally and will fix the ssh permission denied error.


SSH is a must-use when working with a remote Linux server. There are other alternatives, but the protocol offers you a secure remote login. While using SSH, you can encounter the permission denied error which mainly results from a misconfiguration. We’ve seen the various options you can use to resolve this and any of them or at least one will work for your case.

Similar Posts