This topic describes how to run the config command to create a configuration file that is used to store Object Storage Service (OSS) access information. You can add the -c option when you run other commands. This way, ossutil uses configurations in a specific configuration file to access OSS.
For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.
Command syntax
You can run the config command in interactive or non-interactive mode. In interactive mode, you must complete related configurations by using a configuration file before you run the config command. When you run the config command, ossutil directly reads configurations from the configuration file. In non-interactive mode, you must specify parameters when you run the config command. Compared with the non-interactive mode, the interactive mode provides higher security.
Run the config command in non-interactive mode by using the following command syntax:
ossutil config
[-e, --endpoint <value>]
[-i, --access-key-id <value>]
[-k, --access-key-secret <value>]
[-t, --sts-token <value>]
[--ram-role-arn <value>]
[-L language <value>]
[--output-dir <value>]
[-c, --config-file <value>]
The following table describes the preceding options.
Option | Description |
-e, --endpoint | The endpoint of the region in which the bucket is located. For more information, see Regions and endpoints. To specify the protocol that ossutil uses to access OSS, add |
-i, --access-key-id | The AccessKey ID in the [Credentials] section of the configuration file. For more information about how to view the AccessKey ID, see Obtain an AccessKey pair. |
-k, --access-key-secret | The AccessKey secret in the [Credentials] section of the configuration file. For more information about how to view the AccessKey secret, see Obtain an AccessKey pair. |
-t, --sts-token | The Security Token Service (STS) token that is used to access OSS. This parameter is required only if you use STS temporary access credentials to access OSS. For more information about how to generate an STS token, see Use temporary access credentials provided by STS to access OSS. |
--ram-role-arn | The Alibaba Cloud Resource Name (ARN) of the RAM role in RamRoleArn mode for authentication. You must configure this parameter only if you call AssumeRole to access OSS as a RAM user. |
-L language | The language that ossutil uses. Values:
|
--output-dir | The directory in which the output objects are stored. Output objects include the report objects that are generated due to errors that occur when you run the cp command to copy multiple objects at the same time. By default, the directory that is used to store output objects is ossutil_output in the current directory. |
-c, --config-file | The path of the ossutil configuration file. When ossutil is started, it reads the path from the configuration file. |
Examples
Generate a configuration file in interactive mode
ossutil config Specify the name of the configuration file. The file name can contain the file path. The default file name is /home/user/.ossutilconfig. If you press the Enter key without specifying a file path, the configuration file is generated in the default path. If you want to store the configuration file in another path, set the --config-file option to the file path. If you do not specify the path of the configuration file, the default configuration file named /home/user/.ossutilconfig is used. If you press the Enter key without specifying the following parameters, these parameters are ignored. For more information about the parameters, run the help config command. Enter the endpoint: https://oss-cn-shenzhen.aliyuncs.com Enter the AccessKey ID: yourAccessKeyID Enter the AccessKey secret: yourAccessKeySecret Enter the STS token: yourStsToken
Generate a configuration file in non-interactive mode
ossutil config -e oss-cn-beijing.aliyuncs.com -i LTAIbZcdVCmQ**** -k D26oqKBudxDRBg8Wuh2EWDBrM0**** -L CH -c /myconfig
If you specify parameters, except -L language and -c, --config-file, when you run the config command, the non-interactive mode is used. Then, you must specify all parameters.
Modify the configuration file
In ossutil V1.7.15 and later, you do not need to specify Bucket-Endpoint or Bucket-Cname if you use the interactive mode. You can specify an endpoint or a CNAME for each bucket in the configuration file.
ossutil allows you to specify endpoints by using different methods. The following endpoint configurations take effect in descending order: endpoints specified by the --endpoint option in the command, endpoints specified in the [Bucket-Cname] section, endpoints specified in the [Bucket-Endpoint] section, and endpoints specified in the [Credentials] section.
You can modify OSS access information by modifying the generated configuration file. The configuration file of ossutil is in the following format:
[Credentials]
language = CH
endpoint = oss.aliyuncs.com
accessKeyID = your_accesskey_id
accessKeySecret = your_accesskey_secret
stsToken = your_sts_token
outputDir = your_output_dir
ramRoleArn = your_ram_role_arn
[Bucket-Endpoint]
bucket1 = endpoint1
bucket2 = endpoint2
...
[Bucket-Cname]
bucket1 = cname1
bucket2 = cname2
...
[AkService]
ecsAk=http://100.100.100.200/latest/meta-data/ram/security-credentials/EcsRamRoleTesting
[Default]
userAgent = user_agent
loglevel = log_level
proxyHost = proxy_host
proxyUser = proxy_user
proxyPwd = proxy_pwd
readTimeOut = read_time_out
connectTimeOut = connect_time_out
retryTimes = retry_times
Bucket-Endpoint: Specify an endpoint for each specified bucket.
Bucket-Cname: Specify a CNAME for each specified bucket. For more information about CNAMEs, see Map custom domain names.
AkService: This option is required if you want to use a RAM role attached to an Elastic Compute Service (ECS) instance to perform operations on OSS. When you specify this option, you need to only set EcsRamRoleTesting to the name of the RAM role attached to the ECS instance. After you specify this option, you do not need to specify the AccessKey ID, AccessKey Secret, and STSToken parameters. If you specify AccessKey ID, the AkService configuration does not take effect. The AccessKey ID, AccessKey Secret, and STSToken configurations are used to verify your identity. For more information about how to attach a RAM role to an ECS instance, see Grant ECS access to other Alibaba Cloud services by using instance RAM roles.
Default: You can specify this option if you want to modify the default values of common parameters. For more information, see View options.
NoteOnly ossutil V1.7.15 and later support the Default option.