Resolved! Fixes for "PuTTy Server Refused Our Key” Error
Recently, many users have complained the occurrence of an error that reads "Server refused our key" while using PuTTY. It happens when the server you're trying to connect with a PuTTy public key refuses to accept the key provided.
So, without wasting any time, let us dive into practical tips and solutions to troubleshoot the "Server Refused Our Key" error.
A Snapshot of Solutions
Solutions | Overview |
---|---|
Update the PuTTy client to the latest version on your machine. | |
To make sure the private key is in the required .ppk format. | |
Remove the public key authorization and re-authorize it in the SSH session. | |
Make sure all the required file and directory permissions are enabled. | |
Ensure the SSH daemon is configured to allow public key authentication. | |
Use PuTTYgen to regenerate the private key and add it to the server's ~/.ssh/authorized_keys file. |
Proven Ways to Fix "PuTTy SSH Server Refused Our Key"
Implement the below solutions in the same order in an attempt to resolve the "PuTTy via SSH: Server refused our key" error.
Solution 1: Update PuTTy
Not updating the PuTTY client is a leading cause of the refused key error. The first troubleshooting tip is to update the PuTTy to the latest edition. You have several options to update PuTTY.
- Download its latest version from the official site to automatically replace the older one.
- Run the command "Update-Help SSH" on Windows PowerShell to update SSH clients, like PuTTy.
Solution 2: Check SSH Key Format
If you are still getting the SSH server authentication error after updating PuTTy, confirm you're using the right key format. Note that PuTTy, by default, uses the .ppk file format for private keys which is different from the .pem or .pub formats in the OpenSSH.
Thus, if the SSH key is not in the .ppk format, you first need to convert it to ensure successful SSH authentication with the key to the server. Here are the steps to do that:
Step 1: Launch PuTTYgen and click Load.
Step 2: Now, click File > Load Private Key. Browse and select the .pem private key that you're currently using.
Step 3: When it loads, click "Save Public key" to generate a .ppk file. Use this key for authentication in SSH PuTTy to connect to Ubuntu.
When entering the key, make sure all the characters are on a single line, with no leading or trailing spaces.
Solution 3: Re-Authorize SSH Key
This solution is very important to address the issue of the PuTTy key refused. It involves removing the key authorization and then, re-authorizing it inPuTTy on Windows server. While doing so, you also confirm the public key you're using is installed on the server.
Follow the below steps to do that:
Step 1: Open PuTTYgen and load your private key.
Step 2: When it loads, copy the public information of the key as shown in the figure below.
Step 3: Next, remove the key authentication in the SSH session using the below command:
rm ~/.ssh/authorized_keys
Step 4: After that, re-authenticate the key and paste the string you have just copied.
nano ~/.ssh/authorized_keys
Step 5: Save the file and confirm if the key is authorized using the command:
cat ~/.ssh/authorized_keys
Now, close the session and confirm if you are still getting the "SSH: Server refused our key error."
Solution 4: Check SSH Key Permissions
SSH is known for its strict permission mechanism on the .ssh directory and files. You need to enable permissions on both the file and directory of the users. To do that:
1. First enable the 700 permissions on the .ssh directory with the command:
chmod 600 ~/.ssh/authorized_keys
chmod 755 ~
Solution 5: Check PuTTy SSH Server Configuration Issues
If the issue persists, you need to confirm the SSH daemon on the server is configured to allow public key authentication. It is a 3-step process as demonstrated in the steps below:
Step 1: First, allow for editing the SSH configuration file with the below cmdlet:
sudo nano /etc/ssh/sshd_config;
sudo nano /etc/ssh/sshd_config
Step 2: Now, carefully type in and execute the commands to allow authorization:
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
Step 3: Restart the session for these modifications to take effect.
sudo systemctl restart ssh
Solution 6: Regenerate SSH Key
It can occur that the SSH private key is corrupted, hindering the successful authentication with the PuTTy SSH server. In this scenario, it's best to regenerate a new key pair using PuTTYgen.
Here are the steps to do that:
Step 1: Open PuTTYgen and click Generate to create a new private/public key pair.
Step 2: Now, copy the public key information and save the key as a .ppk file.
Step 3: Finally, upload the public key to the server's ~/.ssh/authorized_keys file.
Step 4: Execute the below command to check if the key is successfully integrated into the server:
cat ~/.ssh/authorized_keys
Hopefully, the PuTTy Debian key will successfully authenticate the connection.
Possible Causes for the Server Refused Our Key Problem
As the name implies, this type of error happens when the attempt to access a server is denied. Generally, the error lies in the public-private key pair you using to authenticate the connection. Here are the major factors that often lead to the "PuTTy server refused our key" error:
- Use the incorrect private key file when you try to connect.
- Incorrect key format as PuTTy uses its own .ppk files.
- The public key is not successfully authorized in ~/.ssh/authorized_keys. While adding the key, make sure it's in a single line and doesn't contain breaks or spaces.
- Issues in file and directory permissions. Enable the 700 permissions for Directory and 600 for File.
- If the keys are corrupted, you'll get the refuses our key error.
Bonus Tip: Boost Administrative Efficiency With Remote Desktop Software
If you want a great tool for remote assistance, try AirDroid Remote Support. It comes loaded with all the necessary features to help you effectively control unattended devices, provide or receive remote assistance, and collaborate with your IT teams from anywhere.
Its features like file transferring in bulk, device permission management, and voice chatting, help you increase productivity – and reduce the management costs. This tool is backed by advanced security algorithms and flexible premium plans.
The idea is to make it a go-to choice for both personal use and commercial enterprises.
FAQs
Q1: Can I convert my OpenSSH key to PuTTY's format?
Yes, it's possible to convert the SSH key, which is often in the .pem or .pub format, into PuTTy-supported .ppk format. For that:
- Open PuTTYgen and click File > Load.
- Browse to the path of the private key to load it.
- Then, click the Save public key to save it as a .ppk file.
Q2: What permissions should the .ssh directory and files have?
For successful PuTTy in SSH key authentication, you must enable the following 2 permissions:
~/.ssh directory: 700
authorized_keys file: 600
Q3: How do you check the SSH server logs for key authentication?
To get additional information about why the PuTTy key was refused in Debian or Ubuntu, use the command:
/var/log/auth.log
Final Remarks
This article provides various solutions to resolve the "Server refused our key in PuTTy SSH" problem.As it covers the issues of SSH key configuration, key format, and key permission, one of the solutions is likely to work for you.
Moreover, you must try AirDroid Remote Support as a one-stop solution to meet your personal and business remote management needs. Get uninterrupted access to all the Windows PCs in your organization from anywhere.
Leave a Reply.