I have connected to Elastic Beanstalk using:
eb ssh XXXXXX --profile=xx
Now I want to copy a file to my local machine, how do I do that?
To figure out what IP address and keyfile to use with scp
, you can run
eb ssh my-env-name
and pay attention to the first few lines of output:
INFO: SSH port 22 open.
INFO: Running ssh -i /Users/MyHome/.ssh/eb.pem ec2-user@<eb-env-ip-address>
Then, we can use these details for the actual scp
command (replacing ssh
with scp
and adding file paths):
scp -i /Users/MyHome/.ssh/eb.pem ec2-user@<eb-env-ip-address>:/path/to/file .
You can use regular scp command.
scp -i ~/.ssh/beanstalk-env-key.pem [email protected]:/path/to/file.txt ./file.txt
I think pscl's answer is the best one. Its very easy and is only 2 steps.
But, if you wanted to script it and maybe have only a single step, you could build on Michal's answer here.
scp -i ~/.ssh/yourkey.pem ~/localfile ec2-user@`aws ec2 describe-instances --filters "Name=tag:elasticbeanstalk:environment-name,Values=ENVIRONMENT_NAME" --query 'Reservations[].Instances[].PublicIpAddress' --output text`:~/
You could write an alias pretty easily. The next step would be working out how to dynamically swap in the environment name based on current branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With