s3cmd version 2.1.0 not working with session token - amazon-web-services

i recently updated s3cmd version to 2.1.0. I want to use Temporary Security Credentials which comes with assume role. This is how my ~/.s3cfg file looks like -
[default]
access_key=XXXXXXXXX
secret_key=XXXXXXXXXXXXXXXXXXXX
access_token=FwoGZXIvYXdzEL3//////////wEaDMk0T+yZCPMSV6H6sCKnAaG4EJ9fc5AlWsZxeZpkBpyuvHmylfbz8Ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am getting error :
ERROR: Access to bucket '92xxxxxxx-chef' was denied
ERROR: S3 error: 403 (AccessDenied): Access Denied
while passing keys (access_key, secret_key, access_token) along with command line it's working fine.
~# s3cmd ls s3://928xxxxxxxx-chef/ --access_key=XXXXXXXXXXXX --secret_key=XXXXXXXXXXXXXXXX --
access_token=FwoGZXIvYXdzEL3//////////wEaDMk0T+yZCPMSV6H6sCKnAaG4EJ9fc5AlWsZxeZpkBpyuvHmylfbz8Ie5gRQiHrVFULW4bszAKejZShEXUxZKV0Zqj2J9qY8SlE8Fe6kZ+hgqyJAS4ydfKei4JxSK5xHblRrivKou3yyZgTXzWxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DIR s3://9281xxxxxxxx-chef/git/
DIR s3://9281xxxxxxxx-chef/xxxxxxx-validator/
2020-08-19 14:19 3601 s3://9281xxxxxxxx-chef/chef_init.rb

Related

Unable to locate credentials aws cli

I am using AWS CLI version 2. I am using centos > Nginx > php 7.1, Following command works fine when I directly run on command line.
aws s3 cp files/abc.pdf s3://bucketname/
but when I run same command from index.php file using following code
echo exec("aws s3 cp files/abc.pdf s3://bucketname/ 2>&1");
then it gives error
upload failed: Unable to locate credentials
#Jass Add your credentials in "~/.aws/credentials" or "~/.aws/config" and make it [default] or else use profile_name incase you have multiple accounts.
Also verify, if you are using keys as Environment variables by export, then it will work for that terminal only. So try to execute the php from same terminal where you exported the keys or add it in ~/.aws/credentials.
I tried this and it worked for me and I believe should work for you as well. In your PHP code (index.php), try exporting the credential file location like below
echo exec("export AWS_SHARED_CREDENTIALS_FILE=/<path_to_aws_folder>/.credentials; aws s3 cp files/abc.pdf s3://bucketname/ 2>&1");
When you run from your command-line the AWS CLI picks up the credentials from your home directory i.e. ~/.aws/credentials (this is default). When the index.php is being executed it is looking for the above file in its home directory which appears is not the same as your home directory and hence cannot find the credentials. With the above change you are explicitly pointing it to your AWS credentials.

Errno 13: Permission denied: 'C:\\Users\\myname\\.aws' when running command: AWS Configure

I have AWS_CONFIG_FILE set to C:\Users\myname\.aws
When I run command aws configure and pass in the correct details I get the below error:
[Errno 13] Permission denied: 'C:\Users\myname.aws'
And a credentials file has appeared in folder C:\Users\myname\.aws
But, when I run the command aws configure again, the AWS Access Key ID and AWS Secret Access Key are already set, but the Default Region Name and Default Output Format are [None].
Question 1:: Why hasn't the config file been created?
Then, when I run command aws s3 ls I get error:
An error occurred (SignatureDoesNotMatch) when calling the ListBuckets operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
Question 2: Why am I getting this error and how do I fix it?
It worked with me after deleting the credentials inside .aws and trying again. As per the recommendation here.
I tried the other solutions to no avail. The only way to get it to work was to manually create the 2 files required - config with content like this:
[default]
region=ap-southeast-2
output=json
and credentials like this:
[default]
aws_access_key_id=YOURKEY
aws_secret_access_key=YOURSECRETKEY
On Windows the files go into C:\Users\Username\.aws and neither file has an extension. Afterwards you can confirm it with
aws configure list
on the commandline. Hopes this helps someone!

Downloading multiple files from S3 using 'aws cli' in python

I am trying to download multiple files from S3 using aws cli in python. Using pip install I installed aws cli and was able to successfully pass credentials. But when I try to download multiple files, I get following error:
fatal error: invalid literal for int() with base 10: 'us-east-1.amazonaws.com'
My code to download the file looks like this:
aws s3 cp "s3://buckets/testtelligence/saurav_shekhar/test/" "C:/HD/Profile data/Downloads" --recursive
Also, my C:\Users\USERNAME\.aws\config is
[default]
region = Default region name [None]:us-east-1
output = Default output format [None]: table
I am not sure what that error means and how to resolve this.
The contents of your .aws/config file should look like:
[default]
region = us-east-1
output = table

Not able to upload files on AWS server root folder getting 'file permission error'

I'm trying to upload a google webmaster file to aws root folder with Filezilla. I'm getting the following error
and my root folder permission is set to 755. But still i'm getting file permission error.
You are not authorized to access this directory. Ask your administrator/Root user to run this command.
sudo chown -R USER_NAME:USER_NAME FOLDER_PATH
USER_NAME: Your username
FOLDER_PATH: Folder path
I have also faced the same issue earlier so I sorted it like this.

s3cmd sync S3 Error: 403 Access Denied

I was trying to do
C:\Python27\python s3cmd sync -r K:\a\ s3://test-bucket/test/
on windows. It gives an error
ERROR: S3 error: 403(Access Denied):Access Denied
But the problem is on a different machine with same config for s3cmd, I can push any folder. Only difference is it's linux.
Moreover on earlier machine,
C:\Python27\python s3cmd ls
works fine. Is this a Path problem, then why am I getting access denied? I am logged in as root in both windows (1st machine) and ubuntu(2nd machine).
My bad. I didn't run the command prompt as administrator. I assumed as I was logged in as admin, it does that automatically.
Access Denied was from my end I am assuming for now.