アリクラウドは動的IPをセキュリティグループに追加する


アリ雲のCLIをダウンロードします
https://github.com/aliyun/aliyun-cli/releases
wget https://github.com/aliyun/aliyun-cli/releases/download/v3.0.73/aliyun-cli-linux-3.0.73-amd64.tgz
tar zxvf aliyun-cli-linux-3.0.73-amd64.tgz
sudo cp aliyun /usr/local/bin

Aliyun管理インタフェースを構成し、accesskey API呼び出しを追加してECS管理者権限を追加します.
aliyun configure --mode AK --profile akProfile
Configuring profile 'akProfile' in 'AK' authenticate mode...
Access Key Id []: xxxxxx     #      keyID
Access Key Secret []: xxxxx  #        ID
Default Region Id []: cn-beijing
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en: zh
Saving profile[akProfile] ...Done.
Configure Done!!!
..............888888888888888888888 ........=8888888888888888888D=..............
...........88888888888888888888888 ..........D8888888888888888888888I...........
.........,8888888888888ZI: ...........................=Z88D8888888888D..........
.........+88888888 ..........................................88888888D..........
.........+88888888 .......Welcome to use Alibaba Cloud.......O8888888D..........
.........+88888888 ............. ************* ..............O8888888D..........
.........+88888888 .... Command Line Interface(Reloaded) ....O8888888D..........
.........+88888888...........................................88888888D..........
..........D888888888888DO+. ..........................?ND888888888888D..........
...........O8888888888888888888888...........D8888888888888888888888=...........
............ .:D8888888888888888888.........78888888888888888888O ..............

スクリプトの追加
new_ip=`curl -L ip.tool.lu | head -1 |awk -F ": " '{print $2}'|sed 's/\r//g'`
####
#  --SecurityGroupId    ID
#  --Description   
#  --IpProtocol=          tcp、udp、icmp、gre、all:      
#  --PortRange=22/22                      
#  --SourceCidIp=  IPv4 CIDR   。  CIDR   IPv4   IP    
#  --Priority           1
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId=sg-2zee***** --Description="  IP  " --IpProtocol=tcp --PortRange=22/22 --SourceCidrIp=$new_ip

計画タスクを追加し、実際の状況に応じて調整します.