- Newest
- Most votes
- Most comments
I believe the issue is syntax. First, you don't need to ssh into the box to then run the SCP command. Make sure you are running this locally.
With the SCP command make sure the remote path ends with a /
scp build/libs/app.jar ec2-user@MY_PUBLIC_IP:/home/ec2-user/
That should do it.
If you are getting a "Permission denied" error while trying to upload a JAR file to an AWS EC2 instance using scp, it's likely that you don't have the required permissions to access the destination directory on the instance.
To resolve this issue, you can follow these steps:
Make sure that the destination directory on the EC2 instance exists and that you have the necessary permissions to access it. You can do this by logging in to the instance via SSH and checking the permissions of the directory using the ls -ld command.
Ensure that you have the correct syntax in your scp command. The syntax should be: scp -i /path/to/key.pem /path/to/local/file.jar user@ec2-instance-ip:/path/to/remote/directory/
If the issue persists, you can try changing the permissions of the destination directory using the chmod command: ** chmod 777 /path/to/remote/directory/**
This will give read, write, and execute permissions to all users.
Another solution is to use the sudo command to run scp with elevated permissions: ** sudo scp -i /path/to/key.pem /path/to/local/file.jar user@ec2-instance-ip:/path/to/remote/directory/**
Note: this requires that your user has sudo access on the EC2 instance.
By following these steps, you should be able to upload the JAR file to your EC2 instance using scp without encountering any permission issues.
Relevant content
- Accepted Answerasked 5 months ago
- asked 4 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 16 days ago
This is right, sorry my bad, it works