您可以通过config命令创建配置文件,用于存储配置项和访问凭证。config命令分为交互式命令和非交互式命令,您可以按需进行设置。
创建配置文件
输入配置命令。
ossutil config
根据提示设置配置文件路径。您可以直接回车使用默认的配置文件路径。
以下提示以Linux系统为例。
Please enter the config file name,the file name can include path(default /root/.ossutilconfig, carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):
根据提示分别设置AccessKey ID、AccessKey Secret、地域ID信息。
输入您创建的AccessKey ID。
Please enter Access Key ID [****************id]:LTAI****************
输入您创建的AccessKey Secret。
Please enter Access Key Secret [****************sk]:R6vg*********************
输入您的OSS的数据中心所在的地域ID,如无任何输入,默认值为cn-hangzhou。
Please enter Region [cn-hangzhou]: cn-hangzhou
输入您的OSS的数据中心的Endpoint,如果您不需要自定义 Endpoint,可以直接按回车跳过该参数的配置。
在上一步配置完地域信息后,将默认使用该地域 ID 对应的外网 Endpoint。例如,如果您设置的
region-id
为cn-hangzhou
,默认使用的外网 Endpoint 是https://oss-cn-hangzhou.aliyuncs.com
。如果您需要自定义 OSS 数据中心所在地域的 Endpoint,请输入您的 Endpoint 信息。例如,如果您希望通过与OSS同地域的其他阿里云产品访问OSS,请使用内网Endpoint如
https://oss-cn-hangzhou-internal.aliyuncs.com
Please enter Endpoint (optional, use public endpoint by default) [None]: https://oss-cn-hangzhou-internal.aliyuncs.com
参数说明如下:
参数
是否必填
说明
accessKeyID
是
填写账号的AccessKey,AccessKey的获取方式,请参见创建AccessKey。
accessKeySecret
是
Region
是
填写Bucket所在的地域ID,本文以杭州地域为例,设置为cn-hangzhou,其他地域的ID参见OSS地域和访问域名。
endpoint
否
填写Bucket所在地域的Endpoint。若未手动设置Endpoint,Region将自动生成对应的外网Endpoint,内网需显式指定。例如,本示例使用华东1(杭州)外网Endpoint,设置为
https://oss-cn-hangzhou.aliyuncs.com
。如果您希望通过与OSS同地域的其他阿里云产品访问OSS,请使用内网Endpoint,设置为
https://oss-cn-hangzhou-internal.aliyuncs.com
。关于各地域Endpoint的更多信息,请参见OSS地域和访问域名。
设置和查看配置设置
设置配置设置
ossutil config set
该命令为非交互式命令,设置凭证或配置设置。通过--config-file指定配置文件路径,通过--profile指定 [profile xxx]。
例如,以下命令用于设置myconfig文件中,dev节的region参数。
ossutil config set region cn-hangzhou --config-file myconfig --profile dev
要删除某个设置,请使用空字符串作为值,或在文本编辑器中手动删除该设置。
ossutil config set region "" --config-file myconfig --profile dev
获取配置设置
ossutil config get
该命令为非交互式命令,用于查看凭证或配置设置。通过--config-file指定配置文件路径,通过--profile指定节名。例如,用以下命令查看myconfig文件中,dev节的region参数。
ossutil config get region --config-file myconfig --profile dev
列出所有配置名称
该命令为非交互式命令,列出所有节的名称。
ossutil config list-profiles
快速创建或配置访问凭证
ossutil config credential
该命令为交互式命令,用于快速创建访问凭证设置。其中AK/SK/Token三个参数会涉及用户是否需要加密。
ossutil config credential
The command creates a config file and stores configuration settings and credentials.
Please enter the config file name,the file name can include path(default "C:\Users\issuser\.ossutilconfig", carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):
No config file entered, will use the default config file "C:\Users\issuser\.ossutilconfig"For the following settings, carriage return means skip the configuration.
Please enter profile:
Please enter authenticate mode, supports RamRoleArn,EcsRamRole,Process,Uri,OIDCRoleArn,AK,StsToken:
Do you need to encryt access key id and access key secret (y or N)
Please enter Access Key ID [None]:
Please enter Access Key Secret [None]: