Amazon AWS EC2 Key Pair Denied - linux

I have scoured the Internet for answers and had little luck. All I have been trying to do is connect to my AWS EC2 Linux server via SSH.
The.pem file is on my computer, but it has not been accepted. I have tried several FTP clients, including FileZilla and the native Terminal on my Mac.
In FileZilla, my error is the following:
Error:Disconnected: No supported authentication methods available (server sent: public key)
I also have encountered a similar message in Terminal:
Warning: Identity file rejectedFile.pem not accessible: No such file or directory.
Permission denied (publickey).
I have quadruple-checked the file name corresponds to the one in the AWS console. This file was downloaded when I initialized the instance...

I'd suggest you check also these two common mistakes:
Wrong permissions of the .pem file: make sure the file exists with proper permissions (chmod 400)
Default username: use the proper username for your linux distro
Use the ssh command to connect to the instance. You'll specify the
private key (.pem) file and user_name#public_dns_name. For Amazon
Linux, the user name is ec2-user. For RHEL5, the user name is either
root or ec2-user. For Ubuntu, the user name is ubuntu. For Fedora, the
user name is either fedora or ec2-user. For SUSE Linux, the user name
is root. Otherwise, if ec2-user and root don't work, check with your
AMI provider.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Related

key issues : aws EC2-instance

I am facing some login problem for accessing instance. While login to the server console (its a live server) it shows as Permission denied (publickey), Also am accessing with sudo also same issue persists. AWS instance, should reboot, no change while login issue persists.
As explained in AWS docs your key needs correct permissions:
If you are connecting from MacOS or Linux, run the following command to fix this error, substituting the path for your private key file.
chmod 0400 .ssh/my_private_key.pem
If you got a public key when you set up the server and you saved it (.pem file), you first need to change permissions to it. If in Linux cd to the directory holding the .pem file, then do this:
chmod 400 /path/to/your_public_key.pem for only-read permission.
Then with your EC2 instance public DNS ( get it in AWS EC2 console when you click on your instance ID) which is similar to ec2-x-xxx-xx.us-east-3.compute.amazonaws.com ,you can ssh into your server as follows. Assuming your user account name in the server is ubuntu like in most of the Linux based AMIs in AWS, do:
ssh -i your_public_key.pem ubuntu#ec2-x-xxx-xx.us-east-3.compute.amazonaws.com and if prompted for a password, provide it.
Good luck:)

Linux subsystem ssh don`t see id_rsa.pub

I used to have ssh connection to my server from bash console on Linux subsystem in Windows 10.
I reinstalled Windows and moved id_rsa, id_rsa.pub and known_hosts to exact the same folder where it was on previous system.
But now ssh dont see keys and ends up with error Permission denied (publickey).
But I still can connect using CMD with those keys so issue is not dependig on key file.
On previous system the ssh keys was stored on path: C:\Users\My_Win10_User_Name\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home\My_Linux_Subsystem_User_Name\.ssh so I moved keys to this folder.
What steps should be taking to make ssh on Linux subsystem works again with my old keys?
ssh requires permissions to be correct. Your ~/.ssh directory must be 0700, and the files inside must be 0600. You also don't mention your ~/.ssh/authorized_keys file, which must contain your public key file (the contents of id_rsa.pub.) That file, too, must be chmoded to 0600.

How to use ssh to run a local .sh file (present on a local linux machine) on a remote linux machine (an AWS ec2 instance)

I am having a tough time figuring out a way to execute a .sh file present on my local linux machine on to a remote linux machine which happens to be an AWS ec2 instance.
Here's what I am doing on my local machine:
ssh -i sample.pem ec2-user#server_name.amazon.com 'bash -s' < file_to_remotely_execute.sh
Error that I get is:
Warning: Identity file sample.pem not accessible: No such file or directory.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
This was referred to arrive at the above approach.
Possible issues :
The PEM file doesn't exist.
The PEM file doesn't have proper permissions.
The host is not allowed in ~/.ssh/known_hosts file.
Solutions :
Navigate to the location where PEM file exists or give full path of PEM file.
Give 400 permissions to the PEM file, (sudo chmod 400 /path/to/file.pem).
Login to the server by ssh once, and allow the host.

How do I remove default ssh host from ssh configuration?

I used to connect to Amazon web services using ssh command and application.pem key. Now when I try to connect to other platforms such as Github my ssh client looks for same application.pem key and tries to connect to AWS. How do I connect to Github or change the default host and key configuration.I am using a Ubuntu 13.10 system and following is my ssh output.
pranav#pranav-SVF15318SNW:~/.ssh$ ssh
Warning: Identity file application.pem not accessible: No such file or directory.
You need the identity file to login to the box. Use the command:
ssh -i (identity_file) username#hostname"
This worked for me. Write just the filename (without any slashes), unlike Amazon EC2 tutorial which asks you to enter:
ssh -i /path/key_pair.pem ec2-user#public_dns_name
and also check the permission

Permissions to edit deployed files on amazon ec2 (beanstalk)

I have begun a deployment on amazon ec2 I have deployed my war file and putty(d) in sucessfully to the correct instance using SSH (I generated a key pair)
I am logging in as ec2-user (the default) but the file permissions I need access to are owned by tomcat7.
Any suggestions please on how to su in as tomcat7 (or even root)
ok. I used sudo su and that did the trick!

Resources