WordPress的无法findSSH公钥和私钥对

我的服务器configuration如下:CentOS 5.8(最终)运行Nginx。

我正在使用WordPress的插件安装程序的SSH2function。

我已经安装了lib2ssh ,它正在工作(WordPress的确认它存在)。

我提供给wordpress的用户(叫做playwithbits )是chroot的,主目录是/home/nginx/domains/playwithbits/

公钥和私钥位于目录/home/nginx/domains/playwithbits/keys/ ,分别命名为id_rsa.pubid_rsa

我已将id_rsa.pub的内容id_rsa.pub到位于/home/nginx/domains/playwithbits/.ssh/id_rsa.pub文件

我没有为密钥文件设置密码。 不过,WordPress的不断返回错误:

公共密钥和私钥对playwithbits不正确

我已经向Wordpress提供了以下信息

 Hostname: localhost Username: playwithbits Password: Blank Public key: /keys/id_rsa.pub //I have also tried the paths from server root Private key: /keys/id_rsa 

以下是我在相关文件夹和文件上设置的权限:

 drwx------ 2 playwithbits playwithbits 4096 Jun 8 11:25 .ssh drwx------ 2 playwithbits playwithbits 4096 Jun 8 13:27 keys -rw------- 1 playwithbits playwithbits 414 Jun 8 11:21 authorized_keys -rw------- 1 playwithbits playwithbits 1.7K Jun 6 02:17 id_rsa -rw-r--r-- 1 playwithbits playwithbits 414 Jun 6 02:17 id_rsa.pub 

我也试图连接在debugging模式下,我得到以下输出:

 Connection from 127.0.0.1 port 56674 debug1: Client protocol version 2.0; client software version libssh2_0.18 PHP debug1: no match: libssh2_0.18 PHP debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.8 debug1: permanently_set_uid: 74/74 debug1: list_hostkey_types: ssh-rsa,ssh-dss debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: client->server aes256-cbc hmac-sha1 none debug1: kex: server->client aes256-cbc hmac-sha1 none debug1: expecting SSH2_MSG_KEXDH_INIT debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: KEX done Received disconnect from 127.0.0.1: 11: PECL/ssh2 (http://pecl.php.net/packages/ssh2) debug1: do_cleanup debug1: do_cleanup 

有谁知道为什么我不能使用公钥和私钥访问? 如果我使用帐户的密码,wordpress可以login并执行更新。

编辑:在我的sshd_config文件中,我有以下规则:

 Match group web-root-locked ChrootDirectory /home/nginx/domains/%u X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp AuthorizedKeysFile /home/nginx/domains/%u/.ssh/authorized_keys 

playwithbitsweb-root-locked的成员

我的第一本能: id_rsa应该在〜/ .ssh /

Apache可能是通过fork,children,children等产生各种进程。为此,我会找出Wordpress认为它试图通过使用审计日志工具打开的path。

 `auditctl -a entry,always -F arch=`arch` -F euid!=0 -S open` `auditctl -a entry,always -F arch=`arch` -F euid!=0 -S stat` 

那些应该抓住这个尝试。 您可以通过在您的审计日志上执行grep id_rsa来查找尝试打开。 如果这样不能提供信息,那么深入挖掘chdir监控等就是一条可行的路线,但是我相信open系统调用会抓住这一点。

一旦你知道它想做什么,你可以找出path是相对于用户主目录,另一个用户的家,http根,FS根等。

更新

本教程中使用ssh的Wordpress更新显示使用完整的path来指定密钥。

WordPress的SSH连接信息

通过一些试验和错误find答案。 密钥需要由networking服务器拥有,而不是我正在尝试login的用户。

 chown nginx:nginx id_rsa chown nginx:nginx id_rsa.pub 

现在它像梦一样运作。

试试这个插件 。 它允许您通过浏览器从计算机上传SSH私钥。 公钥不是必需的。

对于那些使用Apache这是我如何解决在Ubuntu 14.04的权限问题

首先添加用户的组,如此apache:

 usermod -a -G myuser www-data 

然后,所有必要的是授予读取私钥的权限:

 chmod g+r /home/myuser/.ssh/id_rsa