Changing the File System Permission
Using the password-based login as the SSH authentication method is not recommended due to security concerns. Therefore, the following solution may be preferable since it troubleshoots the public key authentication method. So, to change the following permission. Step-by-step details are given below:
Step 1: Firstly, open the sshd_config file using a text editor:
sudo nano /etc/ssh/sshd_config
Step 2: In the file, make sure the following options are set as follows:
PermitRootLogin no
PubkeyAuthentication yes
You can check the Screenshot given below for refenrence
Step 3: Comment out the GSSAPI-related options by adding the hash sign at the beginning of the line:
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials no
Example of the action is given below in the screenshot.
Step 5:Ensure that UsePAM line is set to yes:
UsePAM yes
Example of the action:
Step 6: Save the file and restart the sshd service:
sudo systemctl restart sshd
Now navigate to your home folder and check the permissions:
cd home
ls -ld
Example of the action:
Step 7: If your owner permissions are not set to read, write, and execute (drwx——), use the chmod command to change them:
chmod 0700 /home/[your-username]
Now go to the .ssh folder and recheck the permissions:
cd .ssh
ls -ld
- This directory should also have read, write, and execute permissions for the file owner. To enforce them, use chmod again:
chmod 0700 /home/your_home/.ssh
How to Fix SSH Failed Permission Denied
SSH, also known as Secure Shell, is a commonly used method for securely sending commands to a computer network over an unsecured computer network. It uses a cryptographic network protocol for authenticating and encrypting connections between devices. SSH allows for tunneling, or port forwarding, which allows the transfer of data packets across networks. It was developed as a replacement for other unsecured and vulnerable protocols like telnet for seamless solutions for remote access, file transfer, and command-line execution.
SSH operates generally on a client-server architecture, in which a server program accepts or rejects incoming connections, and a client program requests the server for information. Typically, the default port of SSH is 22.
SSH uses public key cryptography to authenticate the remote computer, or, if necessary, allows it to authenticate the server. When a public-private key is generated by the user, authentication is performed when the key pair is generated, and the session will be opened with any password input from the client.