AWS EC2 Instance: ssh_dispatch_run_fatal - amazon-web-services

I just created an EC2 AWS server which I'm trying to SSH into through terminal. However whenever I try to connect I get the following error:
ssh_dispatch_run_fatal: Connection to 18.222.183.247 port 22: Broken pipe
This is the command I entered to get the error.
ssh -i "Key.pem" ec2-user#ec2-18-222-183-247.us-east-2.compute.amazonaws.com
To be clear, I DID select port 22 for this instance per the security rules.

Related

When mounting an S3 bucket on an ubuntu EC2 instance with S3FS, SSH connection is not possible

As stated above, I mounted an S3 bucket with S3FS on an ubuntu instance that I was able to SSH to, and when I restarted the instance, SSH connection to the instance was no longer possible.
ssh command
ssh -i "pem filename" ubuntu#"ec2-domain-name"
Error message
ssh: connect to host "ec2-domain name" port 22: Connection refused
This event did not occur until 2/28/2022, but started to occur on 3/1/2022.
Please let me know if you know the solution or if you have encountered the same issue.

Permission denied (publickey) error while copying to EC2

I'm trying to copy file from my local to Aws EC1 or EC2.
my detailed setup.
Created two EC2 instances.
Got .pem file (Private key) from AWS consle.
Generated private key from .pem file (step2).
Able to connect EC1 and EC2 using private key generated in step 3.
Copied .pem file in EC1 and EC2 servers, by doing that am able to copy files in between EC1 and 2 aws servers.
Now I want to copy the file from my local machine to AWS EC1 and EC2 serves.
But when am trying to do below command (using public DNS):
ssh ubuntu#ec2-18-222-170-204.us-east-2.compute.amazonaws.com
getting below error
Permission denied (publickey)
And when I do it using Private DNS:
ssh ubuntu#ip-172-31-43-162.us-east-2.compute.internal
getting below error:
ssh: Could not resolve hostname ip-172-31-43-162.us-east-2.compute.internal: Name or service not known
what should I do to fix this or make it work?
Output
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "ip-172-31-43-162.us-east-2.compute.internal" port 22
ssh: Could not resolve hostname ip-172-31-43-162.us-east-2.compute.internal: Name or service not known
First thing, ssh ubuntu#ip-172-31-43-162.us-east-2.compute.internal this will only work within VPC, as its private IP and your local system will never able to resolve this DNS until you connect with some VPN from that VPC.
It's not a security group issue, your instance is reachable.
You should post debugs log for ssh ubuntu#ec2-18-222-170-204.us-east-2.compute.amazonaws.com, you can get debug log using ssh -v ubuntu#ec2-18-222-170-204.us-east-2.compute.amazonaws.com
But I am sure it's not picking the pem file from right location. Two possible reason
set chmod 400 your.pem and then try to connect
specify the key in your ssh command
ssh -i path_to_key/private.pem ubuntu#ec2-18-222-170-204.us-east-2.compute.amazonaws.com
Might be possible user ubuntu not exist in that case you can try with root and AWS will return the user which can ssh to that server.
You can also get ssh command for AWS ec2 console. -> Select Instance and click connect, copy the command and try to connect.

EC2 instance gives ssh connection time out error after installing SSL certificate

I am using an Amazon EC2 instance for the last 2 months but today I am unable to connect to it. Earlier I was connecting using ssh and the service is still running (http://ec2-13-233-199-251.ap-south-1.compute.amazonaws.com).
Last night I tried to add an SSL certifcate from Let's Encrypt using this blog: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
After that, when I try to connect to the EC2 instance using ssh as:
ssh -i "majorPillar.pem" ubuntu#ec2-13-233-199-251.ap-south-1.compute.amazonaws.com
I am getting connection time out error.
I checked my security group and port 22 is open and other inbound and outbound rules are correct. How can I connect to my instance now?
the port 22 in your server does not respond, 443 port refuses connections.
Double check your configuration in aws console:
inbound traffic configuration on port 22, ensure your ip address has access to that port.
For example:
nc -zv 13.233.199.251 22
The https certificate install should not have side-effects on ssh config.
Anyway, check /etc/ssh/sshd_config configuration file too and ensure ssh port is the one you want (22?)
sudo grep Port /etc/ssh/sshd_config

Cannot ssh to newly-launched instance in AWS

Several months ago, my friend decided to stop one of his instances. Before stopping it, he created an image of its used to launch it again in the future.
Today, I launch the new instance again from that image, but I cannot ssh into that new instance while I can still ssh into the his old instance. I use the same key pair and security group as the old instance.
The error is: ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused
What are the possible causes and how can I fix them?
Connection refused indicates a network failure when trying to ssh. You shuold make sure your server contains a security group allowing your IP to connect to the server via port 22.
You can resolve the issue by adjusting the permissions of "/var/empty/sshd":
chown root:root /var/empty/sshd
chmod 711 /var/empty/sshd
If it does not solve your issue please share the output of telnet.

Issues with connecting to ubuntu instance in amazon ec2

I am having some issues with connecting to ubuntu instance in amazon. I can connect to the default instance with default AMI installation. But when I select ubuntu, I cannot ssh into it.
It says operation timeout. I have tried instantiating other instances rebooting changing key pairs etc.
ssh -i mykey.pem ubuntu#ec2-54-203-164-37.us-west-2.compute.amazonaws.com
ssh: connect to host ec2-54-203-164-37.us-west-2.compute.amazonaws.com port 22: Operation timed out
The strange thing when I stop the instance, then only the ssh command connects and says the are you sure you want to verify the fingerprint thing.
I can easily log into the micro instance with the default AMI installation
I have added the ssh port in the security group as well
Have you tried connecting via Putty ,just use a ppk file and please check once
also you can add ICMP to your Security Group and check for ping resposnses
Regards
Devashish