couldn't get root access to aws ec2 - amazon-web-services

I'm trying to access aws instance using ssh with private keys downloaded from aws.
I got access using ec2-user which their documentation suggested.
$ ssh -i upd_prayag.pem ec2-user#ec2-54-209-155-100.compute-1.amazonaws.com
Apparently, I find two users there,
ec2-user
prayagupd
What I want is ls the user prayagupd to check whether the directory I have cloned from github exists there.
Unfortunately I see permission denied message on that user.
I get Permission denied (publickey) on
$ sudo ssh -i upd_prayag.pem ec2-user#ec2-54-209-155-100.compute-1.amazonaws.com
They suggest sudo su - should work but it has been asking password, some of the links I found through google is making me anxious that I can't get root access.
Reference
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

If the instance is created from an AWS image, then you cannot get root access.

Related

Permission denied when connection to ec2 intance, i have given the file permisson 400, but still not working

I have created an ec2-intance on AWS. But when im trying to connect to it by using my .pem file, im getting error message: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). I have changed the permission to this file by chmod 400 myfile.pm.
This is the command i use to connect to my instance: ssh -i ec2demo.pem ec2demo#ec2-35-158-140-25.eu-central-1.compute.amazonaws.com
I also searched for the issue on internet, and some people say i need to type chmod 600 myfile.pem. It still not works. Im using macOS Mojave, and the ssh client integrated. Do i need to install the AWS-CLI to make it works? Or should it work without AWS-CLI? And is it better to use ssh client from homebrew, or?
Thanx for help
When launching a new Amazon Linux instance on Amazon EC2, the public half of the keypair is copied to:
/users/ec2-user/.ssh/authorized_keys
You can then login to the instance using the private half of the keypair:
ssh -i key.pem ec2-user#1.2.3.4
(Or, you can use a DNS name instead of an IP address.)
It sounds like you have not logged into this instance yet, so make sure you login as ec2-user instead of ec2demo. The name of the instance does not impact the Linux user on the instance.

Got permission denied in ssh in aws instance

I have install git in my EC2 instance.
git version 2.14.5
I have create a new IAM user and give codeCommit permission.
In next, I have follow all the steps one by one from this link. which works fine.
At the 8th step I have add this code in my config file.
Host git-codecommit.*.amazonaws.com
User {{SSH KEY ID}}
IdentityFile ~/.ssh/id_rsa
Then I have assign 600 to config.
And then I have fire this command to test my SSH.
ssh git-codecommit.us-east-2.amazonaws.com
Error
Permission denied (publickey).
Can any one help me to fixed this issue ?
Can you retry the process with 400 permission on the ssh key
chmod 400 <key>.pem
If your goal is to access a repository from CodeCommit, you can do it with:
git clone ssh://git-codecommit.us-east-2.amazonaws.com/repo-name
If you try to ssh directly to CodeCommit, the connection will be denied with the message:
You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.

Locked out of AWS EC2 Instance - forgot ssh root password?

When I log into my AWS EC2 instance via ssh, all of a sudden I'm being given this error:
-bash: /etc/profile: Permission denied
Super annoying, and it appears as though somehow permissions have been changed (accidentally), and I can't get back in. That said, I've tried logging in as root user vs. ec2-user, but I can't seem to remember the password I set for user root.
How can I recover this password or reset it without root user access? Help!
By default, root user login is disabled on EC2 instances, as documented here:
https://aws.amazon.com/premiumsupport/knowledge-center/set-change-root-linux/
So, unless you explicitly enabled SSH root login, there is no point in trying to find out the root password.
However, ec2-user should be a sudo user itself, try executing
sudo chmod 755 /etc/profile

AWS ubuntu 16.04, permission denied, error code when trying to edit, upload through winScp

I can see my files but not able to edit or delete. How to get permission. Any command?? I want to get root access
you can winscp to /tmp to which all users has access...
to get root access while doing ssh just type following
$sudo su -

How do I configure AMS admin permissions on EC2 AWS?

I created a fresh Adobe Media Server 5 (aka Flash Media Server) instance on Amazon EC2 AWS, I connected over SSH and changed the default password, everything looks ok. But the amsadmin account doesn't seem to have enough access to administrate the instance. I can read most of the files and folders (access denied for /lib; /lost+found and /root).
I can connect ok
ssh -i key.pem amsadmin#public-dns.amazonaws.com
I can upload to the media folder
scp -i key.pem test.f4v amsadmin#public-dns.amazonaws.com:/mnt/applications/vod/media
I can't upload content to webroot; for example if I wanted to add a crossdomain.xml file to the web root.
scp -i key.pem crossdomain.xml amsadmin#public-dns.amazonaws.com:/mnt/webroot/
I can't create a directory; I want to setup S3 to store content, step 5 says to:
Create a directory on the instance to mount the S3 bucket, for example, /mnt/s3fs.
But under the amsadmin account I get an access denied error, is this expected?
How can I get access to these restricted areas?
Update:
I tried executing the commands with sudo and I entered the correct password for amsadmin, got "Sorry, try again".
Do I need to setup a root account?
Figured it out, I needed to run the commands using sudo sh after connecting to the instance via SSH.