Help Center/ Object Storage Service/ obsutil/ Getting Started/ Performing the Initial Configuration
Updated on 2023-08-25 GMT+08:00

Performing the Initial Configuration

Before using obsutil, you need to configure the interconnection between obsutil and OBS, including the endpoint and access keys (AK and SK) of OBS. You can use obsutil to perform operations on OBS buckets and objects only after obtaining the OBS authentication.

Prerequisites

Configuration Method

Method 1: Run the config command to initialize obsutil. For details about the config command, see Updating a Configuration File. The following is an example:

  • In Windows

    Use the permanent AK and SK for configuring initialization:

    obsutil config -i=ak -k=sk -e=endpoint

    Use the temporary AK and SK and security token for configuring initialization:

    obsutil config -i=ak -k=sk -t=token -e=endpoint
  • In Linux or macOS

    Use the permanent AK and SK for configuring initialization:

    ./obsutil config -i=ak -k=sk -e=endpoint

    Use the temporary AK and SK and security token for configuring initialization:

    ./obsutil config -i=ak -k=sk -t=token -e=endpoint
  • After the preceding commands are executed, a configuration file .obsutilconfig will be automatically generated in the user directory (~ in Linux or macOS or C:\Users\<username> in Windows) where obsutil commands are executed. .obsutilconfig contains all the configuration information of obsutil.
  • For details about the parameters in the .obsutilconfig file, see Parameter Description.
  • The .obsutilconfig file contains the AK and SK information of a user. Therefore, it is hidden by default to prevent key disclosure. To query the file, run the following command in the home directory of the user who executes obsutil commands.
    • In Windows
      dir 
    • In Linux or macOS
      ls -a 

      or

      ls -al
  • obsutil encrypts the AK and SK in the .obsutilconfig file to ensure key security.
  • Note: You can use the -i, -k, and -e options to configure user information for authentication. You can run the history command in the Linux OS to query the parameter values. Exercise caution when performing this operation.

Method 2: Implement initial configuration by taking advantage of automatically obtaining access keys for obsutil.

Method 3: Initialize obsutil in interactive mode.

Take a Linux environment as an example.

  1. Run the following command:
    ./obsutil config -interactive
  2. Configure the ak, sk, endpoint, and token parameters.

    The table below describes the parameters.

    Table 1

    Parameter

    Optional or Mandatory

    Description

    ak

    Mandatory

    AK in a permanent or temporary access key pair.

    sk

    Mandatory

    SK in a permanent or temporary access key pair.

    endpoint

    Mandatory

    Endpoint for accessing OBS, which can contain the protocol type, domain name, and port number (optional), for example, https://your-endpoint:80. For security purposes, you are advised to use HTTPS.

    NOTE:

    token

    Optional

    Security token in the temporary access keys. This parameter is mandatory when a temporary access key pair is used. Otherwise, leave it blank.

    For details about config, see Updating a Configuration File.

Checking the Connectivity

After the configuration is complete, you can check whether it is correct by running the following commands:

  • In Windows
    obsutil ls -s
  • In Linux or macOS
    ./obsutil ls -s

Check the configuration result based on the command output:

  • If the command output contains Bucket number, the configuration is correct.
  • If the command output contains Http status [403], the access keys are incorrectly configured.
  • If the command output contains A connection attempt failed, then OBS cannot be accessed. In this case, check the network condition.

If the command output contains Http status [403], you may not have the required permissions for obtaining the bucket list. In this case, further locate the root cause based on the specific situation.