Getting out of the local permissions / server login catch 22
The first step to getting out of the local permissions / server login catch-22 is to know you're in it.
Perhaps you found this page searching for "Permission denied on publickey even though I can log into the server with a public key it doesn't make any sense grrr argh how dare it deny me i created it why won't it work permissions are correct this isn't right" or something like that.
Your problem is that when you run the command without sudo, you don't have the proper permissions locally, and your computer doesn't even try to connect to the server:
Ebony-II:default ben$ scp -r ben@agaricdesign.com:/var/www/drupal-5_2-live/sites/anjaliforberpratt.com/files files
files: Permission denied
But when you add sudo in front, you are actually trying to log into the server from your local computer's root user account, which does not (in this case) have its public key (id_dsa.pub or id_rsa.pub cat'ed to authorized_keys on the server's root account).
Ebony-II:default ben$ sudo scp -r ben@agaricdesign.com:/var/www/drupal-5_2-live/sites/anjaliforberpratt.com/files files
Permission denied (publickey).
What to do? You could download the files you want into your home directory or somewhere else you have permission... or use your sudo powers to make sure you will never get permission denied locally!
Ebony-II:default ben$ sudo chmod 777 .
Now, the non-sudo version of the command works:
Ebony-II:default ben$ scp -r ben@agaricdesign.com:/var/www/drupal-5_2-live/sites/anjaliforberpratt.com/files files
Thank you, and this solution has been brought to you by the How-did-it-take-so-long-to-figure-that-out Foundation.
Comments
Post new comment