7

When I use aws sync, I can set the profile by doimg

aws sync ./test s3://test --profile stage

The profile matches to a set of credentials. I have different credentials for each profile.

How can I use the s3cmd sync command and set a profile as I do with aws sync?

Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

2 Answers2

13

It is easy, just use the -c option to select the "configuration" that you want to use.

Example:

 s3cmd -c my_stage_config sync test s3://test

The default configuration (created with --configure) is stored inside the ~/.s3cfg file.

You can copy it to new files to create different configuration profiles.

zero323
  • 322,348
  • 103
  • 959
  • 935
Florent V
  • 191
  • 1
  • 7
  • 6
    but what's the purpose of the [default] line in .s3cfg? for aws cli I can configure the profile in this line. Then I can use this profile with --profile. So for what purpose this line exists in s3cmd configuration when I can not use profiles? – Ben Jul 10 '17 at 14:05
  • 3
    To answer ChampS, there's a |default] section because it's necessary to make the file a valid INI file but it has no other purpose. It's indeed quite confusing though. – laurent Jan 08 '18 at 11:31
  • agreed - using profiles is so useful when dealing with a variety of accounts. different files is a pain, but not the end of the world. – dave campbell Nov 14 '18 at 22:09
1

Create a profile under the name default, and export AWS_CREDENTIAL_FILE=~/.aws/credentials. You should now be able to run s3cmd. reference

Jing Xue
  • 351
  • 3
  • 4