using SSH in PHP invokes 'Host Key Verification Failed' error
Hi all,
Im trying to do a remote execution of scripts through SSH in PHP. What im doing: -Use PHP in conjunction with nagios' check_by_ssh script to execute the script. -I used Code:
$output = shell_exec('cd /usr/local/nagios/libexec && ./check_by_ssh -H server01 -l nagios -C "/server01/nagios/plugin/check_memory"'); My Qn: How do i get it to work? |
You need an entry in your known_hosts file. There's a system wide one as well as a per-user one. You can just manually run an ssh connection to that server, and then put it's hostkey in your system-wide known_hosts file. I'm not sure but you may need to clean out the PHP users too.
Also, I know PHP has some built in SSH functionality, are you sure you want to be calling a shell process for this? |
Hi,
im currenly tapping on the ssh script for testing purpose. If possible, it will introduce a much simpler solution for my case :) I will give it a try on the system wide known hosts file. Thanks for your feedback. |
Quote:
In my experience, the best way to do SSH from PHP is with phpseclib, a pure PHP SSH client. To do what you're trying to do you'd do something like.... $ssh = new Net_SSH2(); $ssh->login('...', '...'); echo $ssh->exec('...'); |
All times are GMT -5. The time now is 11:07 PM. |