# SSH Connection to Ubuntu 22.04 LTS Instance error

**URL:** <https://forum.ansible.com/t/ssh-connection-to-ubuntu-22-04-lts-instance-error/7547>\
**Category:** Get Help\
**Tags:** ubuntu\
**Created:** [July 30, 2024, 7:13am UTC](https://forum.ansible.com/t/ssh-connection-to-ubuntu-22-04-lts-instance-error/7547 "2024-07-30T07:13:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkflame1](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@darkflame1](https://forum.ansible.com/u/darkflame1)\
**Post date:** [July 30, 2024, 7:13am UTC](https://forum.ansible.com/t/ssh-connection-to-ubuntu-22-04-lts-instance-error/7547/1 "2024-07-30T07:13:31Z")

</div>

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.
