AWS-CLI acccess to S3 on Linux Machine

北战南征 提交于 2020-04-30 11:19:11

问题


I am wanting to set up a recursive sync from a Linux machine (Fedora) to an AWS S3 bucket. I am logged into Linux as root and have an AWS Key and Secret associated with a specific AWS user "Lisa".

I have installed aws-cli, s3cmd, and attempted to configure both. I have verified the aws/configure and aws/credentials files both have a default user and a "Lisa" user with Access Key and Secret pairs. I receive errors stating that Access is Denied, access key and secret pair not found. I have researched this on the web and verified that there are no environment variables that could be overriding the configure & credential files. I have also granted full access permissions to the bucket created through the AWS Console to all logged in users. I have not rotated the keys, as they were first created a week ago, and I was able to log-in & set-up the AWS console using that same key pair.

What else should I be doing before rotating the keys?


回答1:


It looks like you haven't configured AWS credentials correctly. Make sure that you have correct access keys in your credentials file. If you don't specify any profiles, awscli uses the default profile.

~/.aws/credentials

[default]
aws_access_key_id=AKIAIDEFAULTKEY
aws_secret_access_key=Mo9T7WNO….

[Lisa]
aws_access_key_id=AKIAILISASKEY
aws_secret_access_key=H0XevhnC….

This command uses the default profile:

aws s3 ls

This command uses Lisa profile:

aws s3 ls --profile Lisa

You can set an environment variable to override the default profile.

export AWS_DEFAULT_PROFILE=Lisa

Now this command uses the profile Lisa:

aws s3 ls

If you don't know which profile is active, you can just invoke the following command:

aws sts get-caller-identity




回答2:


You seem to have several terms intermixed, so it's worth knowing the difference:

  • Username and password is used to login to the web-based management console. They are short, to be human-readable and easy to remember.
  • Access Key (starting with AKIA) and Secret Key is used for making API calls. It is also used by the AWS CLI (which makes API calls on your behalf)
  • Key pair consists of a public and private key, used for authenticating SSH connections. It is a very long block of text.

You mention that an Access Key is not found. This could be because the wrong type of credential is being provided.



来源:https://stackoverflow.com/questions/57681754/aws-cli-acccess-to-s3-on-linux-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!