Connection closed by EC2 IP - port 22 : <p>Below is the security group(first one) applied to EC2 instance.</p>

<h2><a href="https://i.stack.imgur.com/XCthf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XCthf.png" alt="enter image description here"></a></h2>

<p>Rules for this security group is:</p>

<h2><a href="https://i.stack.imgur.com/sry4x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sry4x.png" alt="enter image description here"></a></h2>

<p>But ssh command give below error:</p>

<pre><code>$ ssh -i ./xyz.pem ec2-user@ec2-xx-xx-xx-xx.ca-central-1.compute.amazonaws.com
Connection closed by xx.xx.xx.xx port 22
</code></pre>

<hr>

<p>Why ssh client is unable to connect to ubuntu instance type?</p>
