轻松地ssh到aws ec2实例
zec2的Python项目详细描述
zec2
轻松管理您的aws ec2实例
安装
pip install zec2
配置AWS凭据
您的计算机上应该有这两个文件:
~/.aws/config
:
[default]region=your_aws_regionoutput=json
~/.aws/credentials
:
[default]aws_access_key_id=your_access_key_idaws_secret_access_key=your_secret_access_key
要了解有关AWS凭据以及如何在您的计算机上安装它们的详细信息,请阅读以下内容: https://docs.aws.amazon.com/rekognition/latest/dg/setting-up.html
不同的AWS配置文件
您可以在aws凭据文件中放置任意多个配置文件,并使用zec2调用它们:
# use default aws profile > zec2 ls # use different aws profile > zec2 -p my_profile ls
对每个命令使用此选项。
cli命令
# list all EC2 instances > zec2 ls # list all EC2 instances using custom aws profile (applies to all commands) > zec2 -p work ls # live list all EC2 instances > zec2 ls -f # ssh to 1st instance from the list > $(zec2 ssh 1)# ssh using different user (the default is ec2-user) > $(zec2 ssh 1 -u ubuntu)# ssh using different pem key path (the default is ~/.ssh/__instance_key_pair__.pem) > $(zec2 ssh 1 -i ~/path/to/key.pem)# stop 1st EC2 instance from the list > zec2 stop 1# start 1st EC2 instance from the list > zec2 start 1# restart 1st EC2 instance from the list > zec2 restart 1# terminate 1st EC2 instance from the list > zec2 terminate 1