How can i remove from my server .pem security check (AWS AMAZON) - amazon-web-services

I got problem. I did opened server from the AWS EC2 AMAZON. Its gived me .pem file. With putty key generator i did changed it to .ppk file. I want to connect my server without .ppk or .pem or any like that file. How can i remove this security check point? Thanks.
Best Regards.

You need to authenticate using the private ssh key when you connect to an EC2 instance. If you don't want to do that, then there are two choices
Recommended : To use new AWS web console ssh connection to your EC2 instance
This is quite a new feature introduced by AWS to ssh into you EC2 instance from the web browser. In your EC2 view, select the instance and click on the Connect button
Not recommended Using password based authentication for a new user.
I wouldn't be providing details on this one as it is not secured to use password based authentication and your should ideally be using the ssh keys based auth.

Related

SSH Key issues on EC2

I am moving from Google Cloud to AWS EC2. Issue I am experiencing is that I am unable to modify SSH keys in any shape or form.
This hinders testing a lot, since any bad key will cause me to redo the key assignation to the instance, etc etc.
I created the keypair directly from AWS (.pem), cannot connect through SSH (Catalina) Permission denied (publickey).
Same when I import the to AWS from my computer. AWS accepts them ok, but then SSH refuses to work.
When I was setting up Google Cloud, I had to match the comment of the public key to the username of the account. Is there anything else like that in EC2?
I would check out connect via Systems Manager service(SSM) and you can connect to your instance via the browser Connect to Linux Instance via SSM

No supported authentication method available when I try to connect to ec2. How to connect to the AWS instance?

I create ec2-instance on the AWS server:
Now I try to connect to the server with putty.
First of all, I downloaded the PPK for instance:
In the next I created a connection with putty:
After I launch connection and set the username as ec2-user:
in the result I got the error:
How to correctly connect to the ec2 instance with PPK?
What I understand from the question is that you did launch an EC2 instance successfully and afterwards you generated a new SSH key pair which does not have any connection to the already created EC2 instance.
What you should have done is to create a new key when the instance was launched:
OR select an existing key:
Now, the easiest way to solve this problem is to terminate the EC2 instance and recreate it with your existing key pair. You should be able to chose wlifter-ppk from the dropdown.
If, for some reason, you don't want to do this or it is not possible to terminate and relaunch the instance, there are several ways to rescue the instance and attach an existing SSH key.
I. Manually rescue the instance:
From Putty convert you .ppk to RSA public key.
Use EC2 Instance Connect or Session Manager to connect to your instance.
Locate the .ssh/authorized_keys file. For Amazon Linux instances this can be found in /home/ec2-user/.ssh folder.
Open authorized_keys, append the new RSA public key and save the file.
Connect to the instance using Putty.
II. Use EC2Rescue tool https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-boot-issues/
I assume you have local Windows and you'd like to connect to your EC2 AWS linux VM.
Use PuTTYgen to generate SSH-2 RSA key, 2048 bits.
Save keys into file, ie. myaws1.pub and myaws1.
In AWS dashboard, find your live instance, open up shell. It'll open up in the browser.
You will be logged in most likely as ec2-user
vi .ssh/authorized_keys
On your Windows, open up myaws1.pub file. take the relevant part and make it one line. Yes, it's broken up into multiple lines. Now press CTRL-C. And over in the browser where you Linux shell, press ESC-I (for insert), now CTRL-V (paste). Save and exit vi.
Back to Amazon Dashboard, in Network Security -> Security Groups, create SSH inbound rule with source 0.0.0.0/0
Now, when connecting to your instance from Putty use "Auth" in options.
This is what your new line in auth file should look like. I shortened it
ssh-rsa AAAAB3......... aws1

Can we create a new user with sufficient permissions to connect on a AWS machine that does not need to use a PEM to RDP/SSH?

Once connecting to a AWS server using the PEM keypair (either RDP or SSH) if we add a new user with local administrator permissions will we be able to logon/SSH without using the original PEM keypair?
Yes.
In fact, it is recommended that once an Amazon EC2 Linux instance is launched, the keypair used for authentication should be replaced with your standard corporate security method.
This might mean creating local users and copying their personal keypairs to their ~.ssh/authorized_keys file, or it might mean using an LDAP or AD server to provide authentication services.
Quick explanation:
When somebody uses SSH with a keypair to login to a Linux instance, the SSH server looks in the requested user's ~.ssh/authorized_keys file. It then tries to match the public keypairs in the file with the private keypair used to establish the SSH session.
If they match, then the login is permitted
Therefore, you can simply replace the keypairs in that file with any desired keypair
This keypair authentication process is a Linux standard and actually has nothing to do with Amazon EC2 itself. However, a helper script on Amazon Linux AMIs will copy the selected keypair into the authorized_keys file on first boot, to make it easier for users to initially login to the instance.

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.

How to connect Mac terminal with EC2 instance

I am using mac terminal and I want to connect my machine with server instance EC2 in aws with SSH. Since I am using Mac OS X is not necessary to use PUTTY. The problem is that when I download the key it is with extension .ppk but when i need to run it on terminal i need to use a command in which i have to use .pem extension . I tried to run it in that way and it said to me permission denied. Can someone help me what to do in this case? Do i have to change the permission or to convert my key from .ppk to .ppm?
You need to know the .pem file folder you download, and then follow steps below:
download the keypair(.pem file)
cd to keypair(.pem file) location (Note that you can use absolute path name for key pair instead)
chmod 400 [your_key_name].pem (Note that to make SSH work, your key must not be publicly viewable. Use this command if needed.)
ssh -i "[your_key_name].pem" ec2-user#[your ec2 dns name]
You will have to convert your "ppk" file to "pem" file follow this steps.
http://www.ramsmusings.com/2014/02/20/converting-a-putty-ppk-file-to-a-pem-file-for-accessing-aws-ec2-instances/
After you convert connect to the instance using the SSH command and converted "pem" file.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
Quick answer
Instead of working directly with SSH keys I would consider working with AWS ec2-instance-connect.
It saves you the the management of the SSH keys and is much safer then sharing SSH keys for each EC2 machine between team members.
After authentication with the aws credentials (by referring to a profile in .aws/config file or using environment variables ) you can connect to the instance very easily by providing the instance ID:
./bin/mssh <instance-ID>
Installation of this tool can be done via pip or directly from the github repo.
Additional information
Amazon EC2 Instance Connect provides a simple and secure way to connect to your instances using Secure Shell (SSH).
With EC2 Instance Connect, you use AWS Identity and Access Management (IAM) policies and principles to control SSH access to your instances, removing the need to share and manage SSH keys.
When you connect to an instance using EC2 Instance Connect, the Instance Connect API pushes a one-time-use SSH public key to the instance metadata where it remains for 60 seconds. An IAM policy attached to your IAM user authorizes your IAM user to push the public key to the instance metadata.
The SSH daemon uses AuthorizedKeysCommand and AuthorizedKeysCommandUser, which are configured when Instance Connect is installed, to look up the public key from the instance metadata for authentication, and connects you to the instance.
You can use Instance Connect to connect to your Linux instances using a
browser-based client,
the Amazon EC2 Instance Connect CLI,
or the SSH client of your choice.
(*) Amazon Linux 2 2.0.20190618 or later and Ubuntu 20.04 or later comes preconfigured with EC2 Instance Connect.
For other supported Linux distributions, you must set up Instance Connect for every instance that will support using Instance Connect. This is a one-time requirement for each instance.
Links:
Connect using EC2 Instance Connect
Securing your bastion hosts with Amazon EC2 Instance Connect