LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-27-2010, 04:28 AM   #1
chuafengru
LQ Newbie
 
Registered: Jun 2010
Posts: 28

Rep: Reputation: 0
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"');
-It gives me a 'Host key verification failed' error even though i enabled it to ssh from my server to server01 without password.

My Qn:
How do i get it to work?
 
Old 09-27-2010, 08:40 AM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 66
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?
 
Old 09-27-2010, 08:32 PM   #3
chuafengru
LQ Newbie
 
Registered: Jun 2010
Posts: 28

Original Poster
Rep: Reputation: 0
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.
 
Old 10-01-2010, 01:26 PM   #4
dinglebat
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
Quote:
Also, I know PHP has some built in SSH functionality, are you sure you want to be calling a shell process for this?
The built in functionality isn't present on most servers and even on those it is present on it has a reputation for being buggy and difficult to use.

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('...');
 
  


Reply

Tags
nagios, php5, ssh


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsa host key error while trying to ssh to server abti Linux - Security 12 01-09-2013 06:45 AM
scp - Host key verification failed. Hellbike Linux - Server 2 05-30-2010 03:16 AM
Ssh problem: Host key verification failed redfeet Linux - Server 3 02-11-2010 11:39 AM
OpenSSH Host Key Verification Failed GodSendDeath Linux - Software 12 01-21-2005 12:28 PM
to 2.6.10 from 2.4.26 | ssh client | Host key verification failed kaN5300 Slackware 6 01-05-2005 10:04 PM


All times are GMT -5. The time now is 07:09 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration