[ACCEPTED]-ssh2_auth_pubkey_file authentication always fails-dsa

Accepted answer
Score: 12

The error in this case was that the keys 11 were generated by the root user, but they 10 need to be accessible by the web server 9 group/owner www-data.

I didn't like the idea of keeping 8 ssh keys in a web folder open to www-data, so I 7 moved the key files to a new user's home 6 directory (/home/keyuser/) then made them accessible to 5 www-data. Authentication was successful.

Even though 4 the original error was saying it found the 3 file, it couldn't read the file.

A better 2 debug method is to try reading the file 1 via php:

$prv_key = file_get_contents('/var/www/application/files/id_dsa');
print "<pre>";
var_export($prv_key);
print "</pre>";

More Related questions