Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Forked from stephaniemdavis/scp-aws.md
Created March 25, 2020 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pythoninthegrass/75cbab4a8eef35c3812e003ea85236ee to your computer and use it in GitHub Desktop.
Save pythoninthegrass/75cbab4a8eef35c3812e003ea85236ee to your computer and use it in GitHub Desktop.
Syntax for using scp to to download a file from AWS to local disk

The following line uses the secure copy protocol to copy a file from an aws instance to the current (".") folder of a local machine.

scp -i aws.pem username@awsip(or ALIAS):/path/to/file .

aws.pem is the key AWS provides you to gain access to the AWS instance you want to copy from.

awsip is the IP address or DNS alias of the AWS instance.

path/to/file is the file's path on aws.

It is extremely important to add the period after the /path/to/file. Note the blank space between the /path/to/file and the period.

https://stackoverflow.com/questions/9441008/how-can-i-download-a-file-from-ec2

The obverse is true too; to upload FROM local folder to aws:

scp -i aws.pem /path/to/LOCALfile username@awsip(or ALIAS:/path/to/file's destination

The code below uses the scp protocol to upload a file FROM my Mac TO the root directory of stephaniemdavis.com:

scp -i LightsailDefaultPrivateKey-us-east-1.pem an.html bitnami@stephaniemdavis.com:/opt/bitnami/apps/wordpress/htdocs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment