简体   繁体   English

我不断收到“主机密钥验证失败”的信息。 在Mac OS X上从PHP调用`ssh`时

[英]I keep getting 'Host key verification failed.' when calling `ssh` from PHP on Mac OS X

I have set up a password-less login from my laptop (OS X) to my dev server (Linux) - this works fine (using ~/.ssh/id_rsa private key, and having put the contents of ~/.ssh/id_rsa.pub into the servers ~/.ssh/authorized_keys file). 我已经从笔记本电脑(OS X)到开发服务器(Linux)设置了无密码登录-可以正常工作(使用~/.ssh/id_rsa私钥,并将~/.ssh/id_rsa.pub的内容放入~/.ssh/id_rsa.pub到服务器~/.ssh/authorized_keys文件中)。 So far, so good. 到现在为止还挺好。

However, I am trying to connect to the server from within a PHP script. 但是,我试图从PHP脚本中连接到服务器。 The Apache server supposedly runs as the _www user, and I have added the necessary hosts line to ~_www/.ssh/known_hosts without solving the problem. Apache服务器应该以_www用户身份运行,并且我已经在~_www/.ssh/known_hosts添加了必要的主机行,而没有解决问题。

I am feeling that there is something basic and fundamental about how Apache on OSX works that I am missing - any suggestions on what I might be doing wrong? 我感觉到我缺少OSX上Apache的工作原理的一些基本知识,关于我可能做错了什么建议?

Thanks! 谢谢!

EDIT: I have confirmed that _www is indeed the currently logged in user, and the home directory is indeed /Library/WebServer . 编辑:我已经确认_www实际上是当前登录的用户,并且主目录确实是/Library/WebServer I added the known host to /Library/WebServer/.ssh/known_hosts , and I also forgot to mention that the private key file has been made readable by the _www user, and when I call the script I call ssh -i /path/to/private.key . 我将已知主机添加到/Library/WebServer/.ssh/known_hosts ,并且我也忘记提及_www用户已使私钥文件可读,并且当我调用脚本时,我调用ssh -i /path/to/private.key

I figured it out - the .ssh directory in /Library/WebServer was owned by root:wheel (like the other files and directories in that directory, thus hiding the fact in plain view...). 我知道了- /Library/WebServer.ssh目录归root:wheel拥有(就像该目录中的其他文件和目录一样,因此将事实隐藏在普通视图中...)。 I changed ownership to _www:wheel , and it works like it should now! 我将所有权更改为_www:wheel ,并且现在应该可以正常工作了! Thanks, and sorry for wasting your time. 谢谢,很抱歉浪费您的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM