scp -r /Applications/XAMPP/htdocs/keypairfile.pem uploads ec2-user@publicdns:/var/www/html
where uploads is a directory returns Permission denied (publickey).
However
scp -i /Applications/XAMPP/htdocs/keypairfile.pem footer.php ec2-user@publicdns:/var/www/html
works (notice the flag change).
uploads is an empty folder
These are the file permissions for the uploads directory
drwxrwxrwx 3 geoffreysangston admin 102 Nov 15 01:40 uploads
These are the file permissions for /var/www/html
drwxr-x--- 2 ec2-user ec2-user 4096 Jan 5 20:45 html
I've tried changing html to 777 and that doesn't work either.
This question is related to
unix
amazon-ec2
file-permissions
scp
If you want to upload the file /Applications/XAMPP/htdocs/keypairfile.pem
to ec2-user@publicdns:/var/www/html
, you can simply do:
scp -Cr /Applications/XAMPP/htdocs/keypairfile.pem/uploads/ ec2-user@publicdns:/var/www/html/
Where:
-C
- Compress data-r
- RecursiveEven if above solutions don't work, check permissions to destination file of aws ec2 instance. May be you can try with- sudo chmod 777 -R destinationFolder/*
transferring file from local to remote host
scp -i (path of your key) (path for your file to be transferred) (username@ip):(path where file to be copied)
e.g scp -i aws.pem /home/user1/Desktop/testFile ec2-user@someipAddress:/home/ec2-user/
P.S. - ec2-user@someipAddress of this ip address should have access to the destination folder in my case /home/ec2-user/
I was initially running:
sudo scp
Once I ran just scp
, without sudo
, it copied everything fine:
scp
It seems to me that sudo scp
command wasn't reading my current user's SSH public key at ~/.ssh/id_rsa.pub
.
Source: Stackoverflow.com