How to solve the problem of connection failure after EC2 instance Ubuntu upgrade

1

My Ubuntu instance is 18.04. When I ran "sudo do-release-upgrade" to upgrade to Ubuntu20.04, it was normal. Other services were also normal. When I upgraded from Ubuntu20.04 to Ubuntu22.04 again, I used winscp and Putty cannot connect to the instance

This is the AWS console instance system log [ OK ] Finished Initial cloud-ini…ob (metadata service crawler). [ OK ] Reached target Cloud-config availability. [ OK ] Reached target Network is Online. [ OK ] Reached target System Initialization. [ OK ] Started ACPI Events Check. [ OK ] Started resolvconf-pull-resolved.path. [ OK ] Started Daily apt download activities. [ OK ] Started Daily apt upgrade and clean activities. [ OK ] Started Daily dpkg database backup timer. [ OK ] Started Periodic ext4 Onli…ata Check for All Filesystems. [ OK ] Started Discard unused blocks once a week. [ OK ] Started Refresh fwupd metadata regularly. [ OK ] Started Daily rotation of log files. [ OK ] Started Daily man-db regeneration. [ OK ] Started Message of the Day. [ OK ] Started Update the plocate database daily. [ OK ] Started Daily Cleanup of Temporary Directories. [ OK ] Started Download data for …ailed at package install time. [ OK ] Started Check to see wheth…w version of Ubuntu available. [ OK ] Reached target Path Units. [ OK ] Reached target Timer Units. [ OK ] Listening on ACPID Listen Socket. [ OK ] Listening on cloud-init hotplug hook socket. [ OK ] Listening on D-Bus System Message Bus Socket. Starting Docker Socket for the API... [ OK ] Listening on Open-iSCSI iscsid Socket. [ OK ] Listening on Socket unix for snap application lxd.daemon. Starting Socket activation for snappy daemon... [ OK ] Listening on UUID daemon activation socket. [ OK ] Reached target Preparation for Remote File Systems. [ OK ] Reached target Remote File Systems. [ OK ] Finished Availability of block devices. [ OK ] Listening on Docker Socket for the API. [ OK ] Listening on Socket activation for snappy daemon. [ OK ] Reached target Socket Units. [ OK ] Reached target Basic System. Starting Accounts Service... [ OK ] Started Amazon CloudWatch Agent. Starting LSB: automatic crash report generation... Starting Deferred execution scheduler... Starting LSB: Daemon for AWSLogs agent.... [ OK ] Started ClamAV virus database updater. Starting containerd container runtime... [ OK ] Started Regular background program processing daemon. [ OK ] Started D-Bus System Message Bus. [ OK ] Started Save initial kernel messages after boot. Starting Remove Stale Onli…t4 Metadata Check Snapshots... Starting Record successful boot for GRUB... [ OK ] Started irqbalance daemon. [ OK ] Started FUSE filesystem for LXC. Starting Dispatcher daemon for systemd-networkd... Starting Authorization Manager... Starting Postfix Mail Transport Agent (instance -)... [ OK ] Started Qualys cloud agent daemon. Starting resolvconf-pull-resolved.service... Starting System Logging Service... Starting LSB: OpenLDAP sta… Directory Access Protocol)... Starting Service for snap application lxd.activate... [ OK ] Reached target Preparation for Logins. Starting Snap Daemon... Starting OpenBSD Secure Shell server... Starting User Login Management... Starting Disk Manager... [ OK ] Started Deferred execution scheduler. [ OK ] Started System Logging Service. [ OK ] Started LSB: automatic crash report generation. [ OK ] Finished Record successful boot for GRUB. [ OK ] Started LSB: Daemon for AWSLogs agent.. Starting GRUB failed boot detection... [ OK ] Finished GRUB failed boot detection. [ OK ] Started Authorization Manager. Starting Modem Manager... [ OK ] Started OpenBSD Secure Shell server. [ OK ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots. [ OK ] Started User Login Management. [ OK ] Started Unattended Upgrades Shutdown. [ OK ] Started Dispatcher daemon for systemd-networkd. [ OK ] Started LSB: OpenLDAP stan…ht Directory Access Protocol). [ OK ] Started Disk Manager. [ OK ] Started Accounts Service. [ OK ] Started Modem Manager. [ OK ] Finished resolvconf-pull-resolved.service. [ OK ] Started containerd container runtime. Starting Docker Application Container Engine... [ OK ] Started Postfix Mail Transport Agent (instance -). Starting Postfix Mail Transport Agent... [ OK ] Finished Postfix Mail Transport Agent. [ * ] (2 of 3) A start job is running for… Container Engine (10s / no limit) M [ OK ] Started Snap Daemon.  Starting Wait until snapd is fully seeded... Starting Time & Date Service... [ OK ] Started Time & Date Service. [ OK ] Finished Wait until snapd is fully seeded. Starting Apply the settings specified in cloud-config... [ 16.893996] cloud-init[2179]: Cloud-init v. 23.3.1-0ubuntu1~22.04.1 running 'modules:config' at Thu, 19 Oct 2023 06:37:29 +0000. Up 16.84 seconds. [ OK ] Finished Apply the settings specified in cloud-config. Starting Permit User Sessions... [ OK ] Finished Permit User Sessions. Starting Hold until boot process finishes up... Starting Terminate Plymouth Boot Screen... [ OK ] Finished Hold until boot process finishes up. [ OK ] Started Serial Getty on ttyS0. Starting Set console scheme... [ OK ] Finished Set console scheme. [ OK ] Created slice Slice /system/getty. [ OK ] Started Getty on tty1. [ OK ] Reached target Login Prompts. [ OK ] Finished Terminate Plymouth Boot Screen. [ OK ] Started libcontainer conta…b859fc96d2ea413d79883d306aab5. [ 18.835068] systemd[1]: Failed to create symlink /sys/fs/cgroup/net_cls: Operation not permitted

Ubuntu 22.04.3 LTS ip-172-31-1-19 ttyS0

ip-172-31-1-19 login: [ 18.939311] cloud-init[2892]: Cloud-init v. 23.3.1-0ubuntu122.04.1 running 'modules:final' at Thu, 19 Oct 2023 06:37:31 +0000. Up 18.89 seconds. [ 19.011435] cloud-init[2892]: Cloud-init v. 23.3.1-0ubuntu122.04.1 finished at Thu, 19 Oct 2023 06:37:31 +0000. Datasource DataSourceEc2Local. Up 19.00 seconds

DD-Boom
asked 7 months ago265 views
2 Answers
0

Hello,

I understand that you are unable to access the ubuntu instance after upgrade to 22.04 via putty or wincp.

I was able to replicate the exact issue on my test environment and was getting below error.

No support authentication methods available (server sent: publickey)

Further I did some research on this issue with 22.04 version of ubuntu and found that “ssh-rsa” is now disabled by default in latest version of SSH(OpenSSH_8.9p1) which is installed on the latest Ubuntu versions. You can see the bug 1961833 to learn how to selectively re-enable it if necessary.

[+]https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1961833

According to the above link you can add below lines in /etc/ssh/sshd_config file and restart SSH service, which will enable RSA/SHA1 for host:-

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

Please see the snippet for reference:

grep -i ssh-rsa /etc/ssh/sshd_config
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

Note : You could update the SSH configuration with above details just before performing reboot after upgrade from 20.04 to 22.04, to avoid connection issue.

Alternatively you can connect to your instances using the sessions manager service to make above changes as the “EC2 instance connect” option is also impacted due to this issue and you will not be able to connect to Ubuntu 22.04 version instance using “EC2 instance connect”. To connect to Ec2 instance using Sessions manager you can follow steps in below link:

[+]. https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started.html

[+]. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/session-manager.html

By default SSM agent should be running on the instance, so next step to use SSM is to attach SSM role to the instance. First of all you need to attach AmazonSSMManagedInstanceCore policy to the instance so that Systems Manager can access the instance.

[1] Let's navigate to IAM service and create a role. 

[2] Choose the service as EC2 

[3] You need to attach ‘AmazonSSMManagedInstanceCore’ policy to the role.

[4] Give a name to the role and finally create the role.

[5] Then you need to attach the role to your instance, by right click on the instance >> select security >> Modify IAM role >> select newly created role >> click update IAM role 

[6]Click on the instance and then click connect >> select session manager >> click connect 

Note : If the connect option is not present after attaching the above IAM role, please wait for 5-10 minutes and also try rebooting the server

Hope this helps. Please do let me know if you have any further queries or concerns. Have a great day ahead!!

AWS
answered 7 months ago
profile picture
EXPERT
reviewed a month ago
0

OpenSSH introduced a change in version 8.9p1 related to the MaxStartups configuration item. In previous versions, MaxStartups allowed larger values (such as 4096), but in the new version, due to the switch to using the ppoll(2) system call, the maximum value of MaxStartups is limited to 1023. This is a change in OpenSSH to accommodate the new ppoll(2) behavior. Since this change may affect old configurations, it is recommended to ensure that the MaxStartups configuration item in your sshd_config file does not exceed 1023. If a larger value is set in your configuration, it should be modified to 1023 or smaller to ensure OpenSSH operates properly. You mentioned some suggestions for possible improvements, such as updating documentation, sshd -t showing errors when checking configuration, or automatically limiting MaxStartups to 1023. These suggestions can be submitted to the OpenSSH community to help improve the software's user experience and documentation accuracy. In summary, make sure your MaxStartups configuration does not exceed 1023 and adhere to OpenSSH's new behavior rules to ensure that your SSH server operates properly. If you set a larger value previously, make sure to change it accordingly in the new version.

DD-Boom
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions