# 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>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.m4lwhere.org/cloud/aws-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
