How to connect to local virtual box instance from amazon ec2 instance - amazon-web-services

I have created a centos7 in my windows machine using oracle virtual box.
I also created and redhat instance in amazon aws.
Now I want to connect from aws ec2 instance to my centos7 instance which is in my windows laptop using SSH.
I have enabled the PasswordAuthentication to Yes in /etc/ssh/sshd_config file in both the machines/instances.
Now in aws ec2 instance I'm trying with below command and it is not showing anything.
ssh user1#122.175.101.188
Please guide me? Am I missed something here?

Make sure that both instances are connected to the internet and have a valid IP address assigned to them.
SSH service is running on your CentOS 7 instance by running the command sudo systemctl status sshd.
,ifconfig on your CentOS 7 instance and looking for the IP address assigned to the network interface you are using.
In your AWS EC2 instance, open a terminal and run the command ssh user1#. Replace with the actual IP address of your CentOS 7 instance.
If this is your first time connecting to the CentOS 7 instance, you may be prompted to confirm the SSH host key fingerprint. Type "yes" to continue.

This typically requires that your local network is configured to allow incoming connections from the Internet, and that your Amazon EC2 instance has the necessary firewall rules and security groups configured to allow outbound connections to your local network. Additionally, you will need to configure any necessary port forwarding or NAT rules on your router or firewall to allow incoming connections to your VirtualBox instance.

Related

Elastic Beanstalk & EC2 Instance Connect: Can't connect

I created an Elastic Beanstalk environment from Visual Studio and need to login to service the underlying ec2 vm.
I don't have an credentials for the server, so I wanted to use EC2 Instance Connect.
When I click connect, I get an error message:
We were unable to connect to your instance. Make sure that your instance’s network settings are configured correctly for EC2 Instance Connect. For more information, see Task 1: Configure network access to an instance.
Following the link, I found the instructions:
Ensure that the security group associated with your instance allows inbound SSH traffic on port 22 from your IP address or from your network.
(Amazon EC2 console browser-based client) We recommend that your instance allows inbound SSH traffic from the recommended IP block published for the service. Use the EC2_INSTANCE_CONNECT filter for the service parameter to get the IP address ranges in the EC2 Instance Connect subset.
How do I connect to the Elastic Beanstalk underlying EC2 via EC2 Instance Connect?
What I've tried:
I created a new security group that contains my client IP address, but that didn't work. Which makes sense, as it's the EC2 Instance Connect app running in the Console making the SSH connection, not my local machine.
Also looked at the the ip ranges json file (https://ip-ranges.amazonaws.com/ip-ranges.json), but not sure what to do with that.
I misunderstood the Set up EC2 Instance Connect instructions. This support article had clearer instructions: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-connect-troubleshooting/
Browser-based SSH connections require that your instance's security group inbound rules allow EC2 Instance Connect access to SSH on TCP port 22.
The key was to find the IP for EC2 Instance Connect and then create
a security group to whitelist that ip address.
EC2 Instance Connect IP can be retrieved via PowerShell by using Get-AWSPublicIpAddressRange (or curl). For us-west-2:
> Get-AWSPublicIpAddressRange -Region us-west-2 -ServiceKey EC2_INSTANCE_CONNECT | select IpPrefix
IpPrefix
--------
18.237.140.160/29
Once I configured my Security Group to use that Source I could connect.
Generally better way then using EC2 Instance Connect is through SSM System Manager. It does not require opening any inbound ports. Instead you should add/modify your install role to allow SSM to work. What's more you can control access to your instance using regular IAM permissions, unlike for EC2 Instance Connect.
Connection through SSM is in the same menu in the AWS console as EC2 Instance Connect. Thus, once you setup your instance role, wait few minutes for the instance to register with SSM, and once this happens you should be able to use SSM System Manager to connect to your instance from the console.
Regarding EC2 Instance Connect IP range. I don't know which range published applies only to EC2 Instance Connect. You would have to filter it by region probably and then find one which works. In worse case scenario its try-and-see approach.

SSH into EC2 instance stalling OS Mojave

I have read several stackoverflow posts, but none seem to help.
I want to ssh into my ec2 instance, so I downloaded the private key file as stated in the instructions from aws. After executing "sudo ssh -v -i ubuntu#", my ssh server hangs with no success or failure message.
I made sure my ec2 instance can accept ssh connections and that my private key file does have the correct permissions. Any other debugging steps to resolve this issue ?
When an SSH connection times-out, it is normally an indication that network traffic is not getting to the Amazon EC2 instance.
Things to check:
The instance is running Linux
The instance is launched in a public subnet, which is defined as having a Route Table entry to points to an Internet Gateway
The instance has a public IP address, which you are using for the connection
The Network Access Control Lists (NACLs) are set to their default "Allow All" values
A Security Group associated with the instance that permits inbound access on port 22 (SSH) either from your IP address, or from the Internet (0.0.0.0/0)
Your corporate network permits an outbound SSH connection (try alternate networks, eg home vs work vs tethered to your phone)
See also: Troubleshooting connecting to your instance - Amazon Elastic Compute Cloud

How to access AWS EC2 instance from web browser on Linux machine?

When I try to connect to my EC2 instance using web browser (Mozilla Firefox) using the third option in the connect (EC2 Instance Connect (browser-based SSH connection) ), I get the following error in the new pop-up window:
There was a problem setting up the instance connection
Log in failed. If this instance has just started up, try again in a minute or two.
Some things to check:
Make sure the instance was launched from Amazon Linux 2 or Ubuntu 16.04 or later
Check that the instance is in a public subnet (defined as having a Route Table that points to an Internet Gateway)
Open the Security Group for SSH (port 22) either for the whole Internet (0.0.0.0/0) (which is a very poor choice for security) or from the IP address ranges for EC2 Instance Connect (See: AWS IP Address Ranges - AWS General Reference)
EC2 Instance Connect in your browser establishes a web connection to the AWS service. Then, the SSH connection is established from the AWS Service to the Amazon EC2 instance. This is why the security group needs to allow incoming connections from the IP address range associated with the EC2 Instance Connect Service (not your own IP address).
Alternative ways to connect are:
Run an SSH client on your computer, or
Use AWS Systems Manager Session Manager (which connects via an Agent running on the computer, so it's not 'real' SSH)

Docker CE installation on Ubuntu 16.04 crashes network

I am trying to install docker-ce 17.09 on ubuntu 16.04 instance on AWS. The instance is behind the company VPC and the security group assigned allows all TCP & UDP traffics.
However, the whole network crashed and I lost SSH connection to my instance when the installation of Docker reached:
Setting up docker-ce (17.09.0~ce-0~ubuntu) ...
Connection reset by ... port 22
Is that because of the VPC settings? Or any other reason?
Updated
As I'm not able to change the existing VPC. I decided not to use Ubuntu instance but amazon AMI instead.
It sounds like your VPC and docker subnets are conflicting. Which means you can either redo your VPC to use a different subnet, or you can change the docker bridge subnet: https://docs.docker.com/engine/userguide/networking/default_network/custom-docker0/

How to establish SSH connection between two machines from different cloud providers?

I have one CentOS instance in AWS and another instance in Hybris Cloud.
The AWS instance is running a Jenkins Server and I want to install a slave for it in the Hybris Cloud Instance.
I have followed the steps to establish SSH connection between two machine but still can't get them to connect.
What am I missing? Is there any special SSH configuration for establishing connection between different cloud providers?
I cant speak for Hybris, but AWS has a security group for your EC2 instance. The security group for your AWS instance must allow port 22 from the IP address of your Hybris server (or a range of IP addresses). In addition, the host firewall on the EC2 Jenkins server must allow for this as well.
Likewise, the Hybris server must have the same ports opened up.
If you continue having issues after checking security groups and host firewalls, check the Network ACL in AWS. If you are in your default VPC and there have been no alterations, the Network ACL should allow for your use case. However if you are in a non-default VPC, whoever created it may have adjusted the Network ACL.