Access key when downloaded as a csv file, doesn't have username field in it, which is needed to configure aws cli

0

When I created an EC2 instance and for that I created access key and secret key pair, and download the same from aws console site, as a csv file, the file just contains 2 rows, access key and secret key, but don't have username field in it.

And when I go into my local ubuntu client shell, and try to configure aws cli there, it asks for the csv file in which my username row also should be given. How come? I've tried many times.

Also, I've tried manually inserting my username in the first row of the csv file, but it didn't work. username=BathindaHelper or user name=BathindaHelper none worked.

  • Can you share any information about how you're trying to configure the AWS CLI? If you just run aws configure it will prompt for your Access Key ID and Secret Access Key (which are in the CSV file), plus your desired default region and output format. You don't need to supply any username for the CLI, all it needs to work are the two values in the CSV file.

  • Just re-reading your question; where are you trying to configure the CLI and what are you trying to do with it?

    If you want to have credentials inside the EC2 instance for use there, it's a best practice to use an instance profile instead of static credentials: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html

    If you want to use the AWS CLI on your local Ubuntu machine to call AWS APIs to control your instance (e.g. start/stop), then you should use the step in my first comment.

  • I'm using ubuntu bash shell which has aws installed. When I try to import the csv file containing my access key and secret, it gives an error saying that csv file doesn't have username in it. Also when I manually configured the secret key method in aws cli console, I don't know what command to use to entire my ec2 instance after that.

    As for other methods of entering into my ubuntu ec2 instance, I really have tired of reading all help aws help documents and trying to use 'Ssh keys' generation method. When I save the pem or ppk public key to my local client pc and try to ssh to ec2 instance, my public key is rejected.

    Also tried 'connect' option of Ec2, in website console, it gives 'Unknown error'.

    In short, there is no way successful to connect (or enter into) my ec2 instance. Only oceans of aws documentation exist.

  • Per the answer posted below, if you're just trying to log in to your EC2 instance, you don't use the AWS CLI for that. You should be able to connect using the .pem it sounds like you're downloading (assuming that's the one specified when launching the instance). You will probably need to chmod 400 it as ssh will refuse to use a key file with too-broad permissions. Finally, make sure to connect using the right username; Amazon Linux uses ec2-user, I think Ubuntu uses ubuntu.

1 Answer
1

Your access key and secret access key are used to talk to AWS APIs as the IAM user you created them for. There is no username for an access key. They are unique to the user you created them for, and when you use them AWS knows who you are. This page of the general documentation might clear things up for you.

It sounds like you're trying to connect to an EC2 instance. In the case of Ubuntu, you need SSH to the server using a SSH key pair (public and private key file) that you generate when you start the instance. See the EC2 documentation for more details about instance keypairs, and how to SSH to an instance.

profile picture
rowanu
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions