Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

scp -r /Applications/XAMPP/htdocs/keypairfile.pem uploads ec2-user@publicdns:/var/www/html

where upload 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 kodeeaws 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.

1 Answer

0 votes
by (44.4k points)

So, -i flag will specify the private key (.pem file) to be used. If you do not provide a private key, it will consider the default private key under the ~/.ssh/ folder.

In the first command, you are asking scp to upload the .pem file itself using the default ssh key. Instead, try this:

scp -r -i /Applications/XAMPP/htdocs/keypair-file.pem uploads/* ec2-user@ec2publicdns:/var/www/html/uploads

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...