ssh2_auth_pubkey_file authentication always fails

て烟熏妆下的殇ゞ 提交于 2019-12-03 11:24:50
James Kirkby

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

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

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

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

$prv_key = file_get_contents('/var/www/application/files/id_dsa');
print "<pre>";
var_export($prv_key);
print "</pre>";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!