官网:https://help.aliyun.com/document_detail/139550.html
aliyun configure set --profile akProfile --mode AK --region aliyun cn-shanghai --access-key-id 你的AK ID --access-key-secret 你的AK密钥
aliyun auto-completion #命令自动补全
aliyun ram ListUsers | grep "UserName" |awk -F "\"" '{print $4}' > /tmp/user.txt
cat>>/tmp/user.sh<<EOF
/bin/bash
echo $1
aliyun ram ListPoliciesForUser --UserName=$1 | grep -E 'Atta|Des'
EOF
chmod +x /tmp/user.sh
awk '{print "sh user.sh " $1}' user.txt | bash
aliyun ecs DescribeInstances --RegionId cn-shanghai --InstanceIds '["i-uf684izq4oceki7p****"]'
aliyun ecs DescribeInstances --RegionId cn-shanghai --pager | grep -E '"InstanceName"|sg' >hostname.txt
#--pager 是导出所有信息,默认导出10条
#查询InstanceName和sg 安全组信息
#取得的值放入hostname.txt中
#对值进行处理
cat hostname.txt | grep "sg-" | awk -F "\"" '{print $2}' > sg.txt #当前sg.txt文件全部为安全组名称
vim sg.sh #编写批量执行脚本sg.sh
#!/bin/bash
echo SecurityGroupId:$1
aliyun ecs DescribeSecurityGroupAttribute --RegionId cn-shanghai --SecurityGroupId $1 --Direction ingress --output cols=SourceCidrIp,NicType,PortRange,Direction,IpProtocol,Policy rows=Permissions.Permission[]
chmod +x sg.sh
awk '{print "sh sg.sh " $1}' sg.txt | bash >port.txt
获得安全组ID对应的所有端口 port.txt
腾讯云CLI介绍:https://cloud.tencent.com/document/product/440/6186
腾讯云:云API 调用出用户
https://console.cloud.tencent.com/api/explorer?Product=cam&Version=2019-01-16&Action=GetUser
cat user.txt | grep -E 'NickName' |awk -F "\"" '{print $4}' #导出所有用户名至excel
cat user.txt | grep -E 'Uin'|awk -F ":" '{print $2}' #导出用户的UIN至excel
合成新的excel文件复制到 id.txt
qcloudcli cam ListAttachedUserPolicies --uin 100022191042 # 测试查看单用户权限
cat>>/tmp/user.sh<<EOF
/bin/bash
#导出用户名
echo $1
#导出权限
qcloudcli cam ListAttachedUserPolicies --uin $2 --output json
EOF
chmod +x /tmp/user.sh
awk '{print "sh user.sh " $1,$2}' id.txt | bash >> cam.txt
#查询安全组ID
qcloudcli dfw DescribeSecurityGroups --output json >>sg.txt #导出安全组名和ID
cat sg.txt | grep sgName |awk -F "\"" '{print $4}'
cat sg.txt | grep sgId |awk -F "\"" '{print $4}'
#复制到excel 拷贝到sg1.txt
#查询安全组规则 ,sg-pc7vv7bb 为安全组ID
qcloudcli dfw DescribeSecurityGroupPolicy --sgId sg-pc7vv7bb --output json
cat>>/tmp/sg.sh<<EOF
#!/bin/bash
#导出用户名
echo $1
#导出权限
qcloudcli dfw DescribeSecurityGroupPolicy --sgId $2 --output json
EOF
chmod +x /tmp/sg.sh
awk '{print "sh sg.sh " $1,$2}' sg1.txt | bash >> sg2.txt
华为云api
https://console.huaweicloud.com/apiexplorer/#/openapi/ECS/doc?api=NovaShowServerAction
华为云CLI介绍:https://support.huaweicloud.com/productdesc-hcli/hcli_01.html
#1:添加yum源
echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo
#2:安装azure-cli
yum install -y azure-cli-2.38.0-1.el7
#3:卸载
yum remove azure-cli -y
rm -rf /etc/yum.repos.d/azure-cli.repo
rm -rf ~/.azure