Permission denied (Public key)

Latest

Have you been tired up of facing the issue of permission denied error? And now you are finding the right place to sort out this problem. Then we are assuring you that you are absolutely in the right place. Here we will discuss some brief and important details related to permission denied issues and then we will discuss that how you can solve this problem. So what are you waiting for? Let’s start this topic.

What is permission denied?

Before getting deep into any topic, we should always discuss some basics. So let’s see briefly that what is meant by permission denied? It’s an error that you can see many times when you are trying to upload any file on your server. No, you will be thinking that why this happens to you? This happens because the file which you are trying to upload does not belong to the correct owner. Or it happens maybe because the file is under someone’s use in current timings.

Reasons for permission denied:

Following are some reasons which can make the issue of permission denied in your work. These errors may happen when you are trying to connect with your Linode through the use of SSH.

  • If you do not have any matching key on your local machine.

Solution: If you are facing this issue then you need to enable the password authentication for your server. The next step is to disable your public key authentication for your server. Now just restart the SSH server.

  • If you have so many keys for your local machine.

Solution: Then you have to make the key specifications. It’s really important to resolve the issue and make the key specification because till then this issue will not be resolved.

  • And if your key is not included in the list of authorized list of Linode. It happens because the file does not exist.

Solution: For fixing this issue, you need to manage the public key manually. You have to insert the public key into your authorized key. You have to do it on your Linode. But if you have not made any public key till now then you may try to disable your public key authentication and then you can enable password authentication.   

Things to see while taking help from a server to fix permission denied error:

You need to see the following things when you are taking help from a server to fix your permission denied error.

1.      See that you are connecting to the right server:

Typing matters when you are connecting to a server. The thing which matters the most is that what you are writing should be accurate and reliable. The server will connect to it automatically. You need to enter the right command to solve this issue.

2.      Verify that the public key is attached to your account:

You must have to give your public key to any secure server for establishing a secure connection. Let’s see the steps to do this process.

  • Open terminal
  • Start SSH terminal in your background
  • Find and take a look at your public key fingerprint.
  • In the top right corner of any page, you just have to click your profile photo and then you have to click the settings.
  • Then in the user’s settings sidebar, click the GPG keys and SSH keys. These are the authentication keys.
  • Now the last step is to compare the list of SSH with your output from the SSH-add command. If your key is not showing on this secure server then you have to give your SSH to it and then do its association to your computer.

3.      Make sure you have a key that is being used:

  • Open terminal
  • See and check that you have generated your private key and then load it into SSH.

After the ssh-add command, it should generate long strips of letters and numbers. And even after this command, you have not generated this then you need to generate it through a new SSH key and then associate it with your desired server.

How to fix SSH permission denied error?

We have two solutions for fixing this problem. But both of the two solutions need to perform some steps on the server-side. The first step is to open the terminal and then the rest of the steps are described below in two different forms of solution.

Solution 1; Enable password authentication:

If you want to utilize a password for accessing the SSH server, an amazing solution to solve this problem is that you need to enable a password log-in into the sshd-config file.

  • For doing this you have to open the file which is present in a text editor. Then in this file find the password authentication line and go with a  “Yes” option in it.
  • In the next step find out the challenge-response authentication option and go with a “No” in this option.
  • Now if the lines are being commented then you can use a hashtag sign to uncomment it.
  • In the last save this file and restart your SSH service by writing the command (sudo systemctl restart sshd.)

Solution 2; Change file permission system:

Due to security concerns, the use of a password-based login is not preferred for the SSH authentication method. Therefore the below solution can become helpful for such scenarios. Follow the below steps;

  • Open the sshd-config file by using a text editor.
  • In your file, you have to see that the below options are set out as we have written them.

Permitrootlogin No

Pubkeyauthentication Yes

But there is a thing that these options are preferable when you are considering the best security practices. If you want to use root login then you can set this line as yes.

  • Now in the next step comment out the GSSAPI related options by using a hash sign at the beginning of this line.
  • Also, make it sure that the UsePam line is set to yes.
  • Now save the file and restart the system. Go to your home and check the permissions.

So this is how you can easily resolve your permission denied (public key) errors.

Leave a Reply

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