LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2016, 12:48 PM   #1
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Rep: Reputation: Disabled
shell_exec - PHP Not working with RSA key


Folks,

I am experiencing an issue where there is a php script which ssh into remote host and get the output of few commands. It was working fine but all of sudden with no changes, it stopped working.
When I try ssh manually using the same key the script use, it works absolutely fine. However this issue happens only through php script.

Below is the command in the script,
Quote:
shell_exec("echo \<FONT FACE="courier"\>;/usr/bin/ssh -i //var/www/html/lte/id_rsa root@xxx
I am seeing the http error in log file whenever i load that php script.

Quote:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
7f:6b:72:2d:49:38:35:9d:51:a1:af:0f:9c:b3:8c:6f.
Please contact your system administrator.
Add correct host key in /var/www/.ssh/known_hosts to get rid of this message.
Offending key in /var/www/.ssh/known_hosts:106
RSA host key for xxxxx has changed and you have requested strict checking.
Host key verification failed.

I know the error is so familiar but I have tried all possible ways mentioned in internet. The error which says "Offending key in /var/www/.ssh/known_hosts:106" . I dont find line 106 on known_host file on both server and client.

I have tried ssh-keygen -R <hostname> on both server and client but no luck.

Could someone give me hand please?

Last edited by pradeepspa; 08-31-2016 at 12:51 PM.
 
Old 09-01-2016, 02:35 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
If you know that the server is the one you trust in and has changed remove the line where the server's key is stored in /var/www/.ssh/known_hosts on the client. The server name or its IP should be in a readable format.
Hope this helps
J
 
Old 09-01-2016, 06:12 AM   #3
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
I have alredy tried that. One think i dont understand is , if you say install server's key in /var/www/.ssh/known_hosts on client side, you mean private key of server?
 
Old 09-01-2016, 06:28 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It is the public key of the host identified in the "known host" file on the system running the PHP script.

One of the things that can do this is upgrades to the remote system, when/if that upgrade replaces the sshd keys. Sshd will generate keys when it starts, thus it will get a new public/private key. Any system that uses the OLD key (as stored in their "known host" file will get a "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED" when they attempt to make a connection.
 
Old 09-01-2016, 06:32 AM   #5
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Thanks. I have manually entered the proper public key which fixed the issue. Thanks a lot folks.
 
  


Reply



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 Key Auth. for connecting to root is not working. Revenge7 Linux - Newbie 6 06-01-2015 02:44 AM
php shell_exec not working with crontab Ranjith KR Linux - General 1 09-03-2013 04:08 PM
Any other method of generating pub key attenuation other than rsa key sanjay87 Linux - Server 1 03-29-2012 09:21 AM
PHP shell_exec with parameters is not working nikeshp Linux - Software 5 01-19-2012 06:51 PM
Putty/SSH login failed when using RSA public key: 'Server refused our key' itsecx@gmail.com Linux - Server 10 10-04-2010 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration