Reputation: 9411
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?
Upvotes: 27
Views: 8934
Reputation: 3402
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 .
Upvotes: 39
Reputation: 3988
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.
Upvotes: 3
Reputation: 1373
You can use regular scp command.
scp -i ~/.ssh/beanstalk-env-key.pem [email protected]:/path/to/file.txt ./file.txt
Upvotes: 14