# AWS CLI

Install via pip

### Create a Profile

This allows us to store the Access Key ID and Secret Key in a ready to use profile.

`aws configure --profile myNewProfile`

After, we can call the profile to ask what info can be gathered about the user.

`aws sts get-caller-identity --profile myNewProfile`

## S3

AWS S3 is used for storage&#x20;

`aws s3 ls --profile myNewProfile`

`aws s3 ls s3://myNewBucket/ --profile myNewProfile`

Copy a file from the bucket to local dir

`aws s3 cp s3://myNewBucket/lol.txt ./ --profile myNewProfile`

Don't forget to check for open buckets!

{% embed url="<https://grayhatwarfare.com/>" %}

## EC2

We can gather information about our instances to include public IPs and security groups

```
aws ec2 describe-instances --profile myNewProfile
aws ec2 describe-instances --profile myNewProfile | jq '.Reservations[] | .Instances[] .PublicIpAddress'
```

Create a keypair to be used in EC2

`aws ec2 create-key-pair --profile m4lwhere --key-name m4lwhere --query 'KeyMaterial' --output text > ~/.ssh/m4lwhere.pem`

## More Notes

{% embed url="<https://0xn3va.gitbook.io/cheat-sheets/cloud/aws>" %}
