您可以通過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.comPlease 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要刪除某個設定,請使用Null 字元串作為值,或在文字編輯器中手動刪除該設定。
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]:
