- 최신
- 최다 투표
- 가장 많은 댓글
Hi there,
Here are the steps you can try:
Login to the first EC2 instance using SSH.
Use the scp command to transfer the file to the second EC2 instance. The command should be in the following format: ruby
scp /path/to/local/file ec2-user@<second-ec2-instance-public-ip>:/path/on/remote/server
Replace /path/to/local/file with the path of the file you want to transfer from the first EC2 instance. Replace <second-ec2-instance-public-ip> with the public IP address of the second EC2 instance. Replace /path/on/remote/server with the path of the directory where you want to store the file on the second EC2 instance.
Enter the password for the ec2-user account on the second EC2 instance when prompted.
Once the file transfer is complete, you should be able to access the file on the second EC2 instance
Let us know if it works.
It's not possible to use the AWS CLI commands for this.
As you've already identified, you can use aws s3 cp ....
and treat an S3 bucket as an intermediate object store to achieve this. But there isn't an equivalent aws ec2 cp [source] [target]
command, which sounds like what your question is about (see aws ec2 help
for the full options).
Tiago's answer here, of using the Linux scp
command, is your best option, assuming that port 22 is open between source and target.
Is there any way to do this without entering a password? For instance by using a IAM role that has EC2FullAccess permission?
scp is not aware of IAM policies. But you can surely use SSH key pairs for passwordless login / file transfer using scp.