SSH Connection to Ubuntu 22.04 LTS Instance error

When I try to ssh into an ubuntu 22.04 EC2 instance using Ansible, I get the following error.
I’ve tried several cases and taken action, but it’s not working.
Is there a solution to this problem?
I also tried adding
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
to the ssh_config file.

sshpass -d10 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘IdentityFile=“/home/ubuntu/ansible/keys/tmp/633826.pem”’ -o ‘User=“ubuntu”’ -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/root/.ansible/cp/b559b71af7 ubuntu-ec2 ‘/bin/sh -c ‘"’“‘echo ~ubuntu && sleep 0’”’"‘’

2024-07-30 04:15:10,013 p=83656 u=root n=ansible | Failed to connect to the host via ssh: OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022^M
debug1: Reading configuration data /etc/ssh/ssh_config^M
debug3: /etc/ssh/ssh_config line 19: Including file /etc/ssh/ssh_config.d/ubuntu-ec2.conf depth 0^M
debug1: Reading configuration data /etc/ssh/ssh_config.d/ubuntu-ec2.conf^M
debug1: /etc/ssh/ssh_config.d/10.70.1.7.conf line 1: Applying options for ubuntu-ec2^M
debug3: /etc/ssh/ssh_config line 19: Including file /etc/ssh/ssh_config.d/xx.x.xx.xx.conf depth 0^M
debug1: Reading configuration data /etc/ssh/ssh_config.d/xx.x.xx.xx.conf^M
debug3: /etc/ssh/ssh_config line 19: Including file /etc/ssh/ssh_config.d/xx.x.x.xx.conf depth 0^M
debug1: Reading configuration data /etc/ssh/ssh_config.d/xx.x.xx.xx.conf^M
debug1: /etc/ssh/ssh_config line 21: Applying options for *^M
debug2: resolve_canonicalize: hostname ubuntu-ec2 is address^M
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts’ → ‘/root/.ssh/known_hosts’^M
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts2’ → ‘/root/.ssh/known_hosts2’^M
debug1: auto-mux: Trying existing master^M
debug2: fd 3 setting O_NONBLOCK^M
debug2: mux_client_hello_exchange: master version 4^M
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote^M
debug3: mux_client_request_session: entering^M
debug3: mux_client_request_alive: entering^M
debug3: mux_client_request_alive: done pid = 83662^M
debug3: mux_client_request_session: session request sent^M
debug1: mux_client_request_session: master session id: 2^M
debug3: mux_client_read_packet: read header failed: Broken pipe^M
debug2: Received exit status from master 1^M
Shared connection to ubuntu-ec2 closed.

Thank you in advance.