I have been using Amazon EC2 instances in AWS. I have been successful connecting with WinSCP to a variety of instances, including Amazon Linux, Rocky Linux, SUSE, and CentOS 6, 7, and 8. All of those instances with other OSs have succeeded using a particular combination of
- Key pair (login)
- VPC
- Subnet
- Firewall (security group)
Therefore, it does not seem to be plausible that any of those choices are at fault.
In WinSCP, I can clone working WinSCP configurations from other instances and then (after adjusting the new site for the changed "Host name" and using the suggested login username of "ubuntu") I can try to connect just like I would for the others that worked. Therefore, it does not seem to be plausible that the problem is an incorrect WinSCP configuration (unless I should be using something other than "ubuntu" as the default username).
The instance is seen, but the attempt to login fails for the Ubuntu instance only.
No supported authentication methods available (server sent: publickey)
and
Using username "ubuntu".
Server refused our key.
Authentication failed.
I've looked through some of the other questions that have to do with "Server refused our key", but this isn't a problem with the key pair itself, since it works with many other instances. Nor does it seem feasible that it could be any of the other common elements that have been working for other instances. The error message itself indicates that it did see the recommended login username of "ubuntu" (and I even tried other usernames that are sometimes used for AWS instance logins such as ec2-user, admin, root, but those didn't work either).
I've also tried creating a second instance to check if there was some fluke or mistake about making the first instance, but there was no difference.
Since this failed login is for the initial login attempt to the default user, I cannot login as a different user and poke around inside or change the instance.
If it matters, I was using
Minimal Ubuntu 22.04 LTS - Jammy
https://aws.amazon.com/marketplace/pp/prodview-o5bowpuwmx3ng
UPDATE 1: The same happens for
Ubuntu 22.04 LTS - Jammy
https://aws.amazon.com/marketplace/pp/prodview-f2if34z3a4e3i
I wonder if there is something different in how Ubuntu handles the communication that requires a different setting than any other OS that has worked.
UPDATE 2: Based on a clue from the answer by rahul jain, I tried a quick test using an instance based on the previous Minimal Ubuntu LTS release.
Minimal Ubuntu 20.04 LTS - Focal
https://aws.amazon.com/marketplace/pp/prodview-meawmysinhrrs
That one worked fine. Therefore, it does seem that the issue is a change since 20.04 Focal Fossa, and it seems likely that it is related to authentication changes that require a more recent PuTTY codebase, as rahul jain suggested. I will do more testing, but the answer is looking good so far.