注意:该文档为旧版命令行工具配置文档,已不再维护,建议您使用新版命令行工具,可查阅新版 命令行工具 TCCLI 操作文档。
要使用腾讯云命令行工具,您还需要进行一些初始化配置,使其完成使用 云 API 的必要前提条件。
密钥获取
- 登录腾讯云 API 密钥控制台。
- 新建密钥或使用现有云 API 密钥。单击云 API 密钥 ID进入详情页,获取 SecretID 及 SecretKey。
配置命令行工具
执行以下命令:
$ qcloudcli configure
Qcloud API SecretId [****************cQ]:******************************aBCDP
Qcloud API SecretKey [****************ArFd]:****************************ArFd
Region Id(gz,hk,ca,sh,shjr,bj,sg) [hk]: gz
Output Format(json,table,text) [json]: json
用户需要输入:
- 云 API 密钥 SecretId;
- 云 API 密钥 SecretKey;
- 默认地域 Region Id:目前支持
gz、hk、ca、sh、shjr、bj、sg
7个地域。 - 结果输出形式 Output Format:支持 json、table、text 三种形式。
配置完成后随机使用一个命令来测试结果:
- 如果配置正确则返回CVM设备信息
$ qcloudcli cvm DescribeInstances
{
"instanceSet": [],
"totalCount": 0,
"message": "",
"code": 0,
"codeDesc": "Success"
}
- 如果配置错误则返回鉴权失败
$ qcloudcli cvm DescribeInstances
{
"codeDesc": "AuthFailure",
"message": "鉴权失败,SecretId 不存在",
"code": 4100
}
更多配置相关命令
添加账号
使用以下命令添加新帐号:
$ qcloudcli addprofile
New profile name: test
Qcloud API SecretID: test
Qcloud API SecretKey: test
Region Id: gz
Output format:json
查询账号信息
$ qcloudcli showconfigure
------------------------------------------------------------------------------------
| showConfigure |
+----------------------------------------------------------------------------------+
|| Configure ||
|+--------------------------------------------------------------------------------+|
||| default profile |||
||+--------------------------------------+---------------------------------------+||
||| output | region |||
||+--------------------------------------+---------------------------------------+||
||| json | hk |||
||+--------------------------------------+---------------------------------------+||
||| profile clitest |||
||+--------------------------------------+---------------------------------------+||
||| output | region |||
||+--------------------------------------+---------------------------------------+||
||| json | GZ |||
||+--------------------------------------+---------------------------------------+||
|| SecretId and Key ||
|+--------------------------------------------------------------------------------+|
||| default profile |||
||+----------------------------------------+-------------------------------------+||
||| qcloud_secretid | qcloud_secretkey |||
||+----------------------------------------+-------------------------------------+||
||| ********************************8s0o | ****************************jmTS |||
||+-------------------------------------+----------------------------------------+||
||| profile clitest |||
||+-------------------------------------+----------------------------------------+||
||| qcloud_secretid | qcloud_secretkey |||
||+-------------------------------------+----------------------------------------+||
||| AAABBBCCC | AAABBBCCC |||
||+-------------------------------------+----------------------------------------+||
修改指定账号信息
$ qcloudcli configure --profile clitest
Qcloud API SecretId [****************BCCC]: test
Qcloud API SecretKey [****************BCCC]: test
Region Id(gz,hk,ca,sh,shjr,bj,sg) [GZ]: gz
Output Format(json,table,text) []: json
设置默认账号
$ qcloudcli useprofile --name clitest