Keywords: SSH authentication failure | PuTTY key issues | Server configuration troubleshooting
Abstract: This paper provides an in-depth examination of the common SSH error "disconnected: no supported authentication methods available (server sent: publickey, gssapi-with-mic)". Through analysis of specific cases in PuTTY usage scenarios, we systematically identify multiple root causes including key format issues, server configuration changes, and software version compatibility. The article not only presents direct solutions based on best practices but also explains the underlying principles of each approach, helping readers build a complete knowledge framework for SSH authentication troubleshooting. With code examples and configuration analysis, this paper demonstrates how to effectively diagnose and resolve authentication failures to ensure stable and secure SSH connections.
Problem Phenomenon and Background Analysis
When using PuTTY for SSH connections, users may encounter the error message "disconnected: no supported authentication methods available (server sent: publickey, gssapi-with-mic)". This error indicates a mismatch between client and server authentication methods: the server declares support for publickey and gssapi-with-mic authentication, but the client cannot provide acceptable credentials for either method.
Core Problem Diagnosis
Based on case studies, this issue typically involves several key aspects:
Key Management and Format Compatibility
PuTTY uses its proprietary PPK (PuTTY Private Key) format for storing private keys, while most SSH servers (including AWS EC2) expect standard OpenSSH format keys. When key formats mismatch, authentication fails even if the public key is correctly uploaded to the server. For example, when generating or converting keys in PuTTYgen, attention must be paid to PPK file version selection:
# Example of correct key conversion process
# 1. Load PEM format private key in PuTTYgen
# 2. Set PPK version to 2 in "Parameters for saving key files"
# 3. Save as PPK format private key
Version 3 PPK format may not be supported by some servers, leading to "PuTTY key format too new" error messages.
Server Configuration Changes
The SSH configuration on the server side (sshd_config) may have been accidentally modified. Critical configuration items include:
# Relevant configurations in /etc/ssh/sshd_config
PasswordAuthentication no # Disable password authentication
PubkeyAuthentication yes # Enable public key authentication
AuthenticationMethods publickey # Specify authentication methods
If PasswordAuthentication is set to no and the client cannot provide valid public key authentication, the described error will occur. A temporary solution is to change this value to yes and restart the SSH service, though this reduces security.
Software Version and Compatibility Issues
Outdated versions of PuTTY and PuTTYgen may cause incompatibility with new encryption algorithms or key formats. Keeping software updated to the latest version (such as 0.76 or above) can resolve many compatibility issues. After updating, regenerating or converting keys typically fixes authentication failures.
Systematic Solution Approach
Based on best practices and multiple successful cases, we recommend the following systematic troubleshooting and resolution process:
Step 1: Verify Key Integrity
First, check whether the key pair is complete and correctly formatted. When reloading PEM files in PuTTYgen and saving them as PPK format, ensure the correct key type (such as SSH-2 RSA) and PPK version (version 2) are selected. Key operations include:
// Pseudocode: Key verification process
if (key_comment.contains("imported-openssh-key")) {
// Key format is correct
proceed_with_authentication();
} else {
// Key needs reconversion
convert_pem_to_ppk_v2();
}
Step 2: Check Server Configuration
Connect to the server through alternative means (such as using standard OpenSSH client) to examine authentication-related settings in the sshd_config file. Focus on:
- Whether
PubkeyAuthenticationis enabled - Whether the
AuthorizedKeysFilepath is correct - Whether firewall or SELinux policies are blocking authentication
Step 3: Complete Key Reset Procedure
When the above methods prove ineffective, performing a complete key reset is the most reliable solution. This process includes:
- Delete all old public keys from the server's
~/.ssh/authorized_keysfile - Generate a completely new key pair using PuTTYgen on the client
- Upload the new public key to the server's
authorized_keysfile - Wait for SSH service cache updates (typically several minutes to half an hour)
- Reconnect using the new private key
The effectiveness of this method lies in its complete elimination of all possible key-related failure points, including key corruption, permission issues, and format mismatches.
Step 4: Software Updates and Compatibility Testing
Ensure the latest version of the PuTTY suite is used, and test compatibility with different key formats. For cloud environments like AWS EC2, also verify that the instance's SSH service configuration aligns with the cloud provider's best practices.
Technical Principles Deep Dive
SSH authentication involves complex protocol interactions. When a client initiates a connection, the server sends its list of supported authentication methods. The client must select one and provide corresponding authentication credentials. If the client's credentials are not accepted (such as malformed public keys), or if server configuration restricts available authentication methods, the "no supported authentication methods available" error occurs.
From a protocol perspective, this error occurs during the "user authentication" phase of SSH. The server informs the client of authentication failure via the SSH_MSG_USERAUTH_FAILURE message, accompanied by the list of available authentication methods. If the client cannot attempt other methods, it disconnects and displays the error message.
Preventive Measures and Best Practices
To prevent similar issues, we recommend the following preventive measures:
- Regularly update PuTTY and server SSH software to the latest stable versions
- Use standardized tools and processes for SSH key management, avoiding manual key file modifications
- Configure multiple authentication methods on servers as backups (e.g., enabling both public key and password authentication)
- Establish key rotation mechanisms to periodically update SSH key pairs
- Use configuration management tools (such as Ansible, Puppet) to ensure SSH configuration consistency
Conclusion
While the "disconnected: no supported authentication methods available" error appears singular in manifestation, its root causes may involve multiple layers including key management, server configuration, and software compatibility. Through systematic diagnostic methods and solutions based on best practices, SSH connections can typically be restored quickly in most cases. Most importantly, establishing comprehensive SSH key management processes and server configuration standards fundamentally prevents such issues from occurring.