Can't remote into a spawned EC2 instance - amazon-web-services

I am not able to remote desktop into a T2.micro instance that I spawned from the AWS Java API. Here is what I did:
Created an instance using the Amazon console
Successfully remoted into it
Created an AMI of the instance
Wrote a Java program to runInstance using the same security group, availability zone, subnet, and keyname as the original
Ran the program and saw it start successfully
Tried to connect and got the message: "Password is not
available. This instance was launched from a custom AMI, or the
default password has changed. A password cannot be retrieved for
this instance. If you have forgotten your password, you can reset it
using the Amazon EC2 configuration service"
Am I missing something? Shouldn't this work?

When you say Tried to connect and got the message "Password is not available", do you mean you connected with RDP or do you mean that you were in the AWS console, you right-clicked the EC2 instance and you selected "Get Windows Password"?
Unless you explicitly did something to prevent it (see below), I would expect the administrator password of the new instance to be the same as the old instance.
If you want a new administrator password for the new instance, then you need to use the EC2ConfigService on the original instance and configure it so that a new password is generated on next boot. Then you can stop the instance and create an AMI from it. When a new instance is launched from the AMI, it should then allow you to retrieve a new password.

Related

How do I connect to EC2 instance in AWS?

I am trying to connect to an EC2 instance with the key. But I get an error saying
No supported authentication methods available (the server sent: public key")
In the command window I get:
Using username "ec2-user"
Server refused our key
. Please help me
I will try to help! Suppose you are trying to connect using the PuTTY SSH client on your local machine. (Connecting with an FTP client like WinSCP is very similar).
Short answer: You need to let PuTTY know your ec2user IP address and associate the private key of the EC2 instance with the PuTTY session. On the AWS side you need to create a security group that allows inbound access from your IP address to your EC2 instance for SSH on port 22.
__
Long answer 😊:
Go to your EC2 page and click [CONNECT]
[]1
Copy the ec2User IP address to PuTTY.
When you created the EC2 instance, you were prompted to download the public/private key pair. You need that private key. If you don’t have that file, things are more complicated. (See Change key pair for ec2 instance).
But hopefully, you can find the private PuTTY Private Key file downloaded on your local machine:
Save the session. PuTTY should be all set up now.
Now on the AWS side, you need to make a new security Group:
Create the group and ADD an Inbound Rule:
Go back to EC2 and add security group to EC2.
In the dialog that pops up, check the security group that you just created for PuTTY remote access and click [Assign Security Groups]
Now give it a try!
I hope this works for you like it does for me.
ONE FINAL TIP: Make sure that you associate an Elastic IP address to the instance. Otherwise, this connection might stop working when someday you reboot your EC2. The elastic IP pins it down.
Verify that you are connecting with the appropriate user name for your AMI. Type the user name in User name in the PuTTY Configuration window.
The appropriate user names are as follows:
For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.
For a CentOS AMI, the user name is centos.
For a Debian AMI, the user name is admin or root.
For a Fedora AMI, the user name is ec2-user or fedora.
For a RHEL AMI, the user name is ec2-user or root.
For a SUSE AMI, the user name is ec2-user or root.
For an Ubuntu AMI, the user name is ubuntu.
Otherwise, if ec2-user and root don't work, check with the AMI provider.
You should also verify that your private key (.pem) file has been correctly converted to the format recognized by PuTTY (.ppk).

Unable to ssh to instance after changing port

I have a running EC2 instance on which one of the database having transactional records stored through the application running on the same instance. I've change the port due to some security reasons but after changing port I'm unable to SSH to the instance.
My security group and NACL both having old as well as new port configured in it.
I've tried to SSH several times but it gives error Network Error: Connection timeout.
I'm scared about to data lost if this instance gets stopped. Need help!
You can login to instance without losing data with the help of 'session manager' option under the "System Manager". You will need to complete certain per-requisites of the session manager as follows given in the Amazon docs for Systems Manager Prerequisites
After completing the per-requisites assign the IAM role to the EC2 instance created for SSM.
Into the AWS console, search for the session manager option under the System manager and your instance ID will get listed over there.
Select the instance and choose for the Start session, you will get the shell console of your instance.
Revert the changes made in /etc/ssh/sshd_config for the port and try to SSH again.

Amazon AWS EC2 Instance Not Connecting

I am attempting to create and connect to an Amazon EC2 instance via FidOS. I am following the procedure demonstrated in:
How to Create Amazon AWS EC2 Instance
I logged onto the AWS Console and created a general purpose Ubuntu Server Machine image.
I configured the instance details, added storage, added tags, and configured the Security Group just as in the video.
I clicked "Review and Launch" and created and downloaded the PEM key.
I generated the PPK private key using PuttyGen.
I configured my session using the public DNS in the Host Name field and uploading the private PPK key in the Authorization tab.
After I clicked Open, a terminal window appeared, but then timed out.
I am working on a Windows machine, and trying to create a Ubuntu Linux virtual machine.
Am I missing any steps or doing anything wrong? I would appreciate any help I can get.
The problem was the corporate firewall. It worked just fine when I tried it from another location.

Amazon AWS EC2 Ubuntu Instance - how to SSH?

New to Amazon AWS here. I setup a new ubuntu instance but cannot SSH to the instance. How do I find the login/password for SSH? I don't remember one being shared with me when I created that instance.
I added my IP to inbound traffic for the security group
I setup a key and am using the key with my Putty connection
I am able to get to the login step, but when I enter 'root' as the login (or any value), I get:
Server refused our key
Disconnected: No supported authentication methods available (server send: publickey)
when you deploy an EC2 instance in AWS, you'll be asked to select existing key-pair or create new one. if you choose to create new one, AWS will give you the keypair.
after new key-pair is downloaded, you need to change the key permission.
If you deploy an Ubuntu instance, the user usually ubuntu.
ssh -i key.pem ubuntu#yourinstanceIP
or you can select the instance, and you can click on Connect button.

can't ssh in after cloning an EC2 instance on Amazon AWS

I have a working m3.large instance on Amazon AWS that I'm able to login to using a username and a password via ssh. I've cloned it by creating an AMI of it and then spinning up another m3.large instance based on that AMI, but I cannot ssh into it. In putty, after typing in my username, I get "Server refused our key"
followed by Disconnected: No supported authentication methods available (server sent: publickey). Shouldn't the new cloned instance behave exactly like the one the AMI came from? Shouldn't the only difference be their IP addresses?
Ok i figured out that the problem was in the original instance, the one I'd cloned. In its /etc/ssh/sshd_config, i'd neglected to include the line PasswordAuthentication yes For some reason even with it set to no I could login on the original instance, but not on the clone.