SSH key for Apache user
Posted by: OlivierP (---.ir.intel.com)
Date: September 16, 2014 11:38AM

Hello,

After searching for a while, I have a headache. smiling smiley


Here is my problem:

Thru a php web page, I use the exec command to call the ssh command to a server (Gerrit). This ssh returns results that I need.

The server only allows ssh queries if a ssh key has been defined.

The problem is that with wampserver, the apache user (found with echo shell_exec('whoami')winking smiley is nt authority\system.
And I don't know how to create an id_rsa.pub for that user.

I hope I'm clear. ^_^

Many thanks in advance.

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: September 20, 2014 07:46AM

This is not the solution! As my user for Apache is also 'nt authority\system' and so is everybody else that uses WAMPServer.

Look at this PHP Manual, ssh2_connect

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: OlivierP (---.ir.intel.com)
Date: September 29, 2014 11:14AM

Ok, thanks. I'll see that.

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: OlivierP (192.198.151.---)
Date: September 29, 2014 01:36PM

Does not work. Not really easy to use ssh2 under Windows.

I do not really understand why we cannot create a ssh key for the Apache user.

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: September 29, 2014 04:58PM

Because your apache user is the same as everybody elses apache user, well everyone using Apache on windows anyway. So therefore its not exactly unique. Unless I am misunderstanding completely!

I would say you would have to login to ssh using a userid/password pair that
a) you can manage from some admin tool.
b) that you can easily change both userid and password if wither the userid or password were ever compromised.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 09/29/2014 05:00PM by RiggsFolly.

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: OlivierP (---.ir.intel.com)
Date: September 30, 2014 11:38AM

Thanks for your help.

I tried with NET_ssh, but in fact it's a little bit more complicated.

The gerrit server does not allow to connect with ssh. I mean when I type (in a terminal): ssh www.server.com, I get a return saying that the connection works, but I'm not logged in. I stay in my computer.

The command I need to execute is something like that: ssh www.server.com gerrit query ...
It will returns a JSON with what I want.

That's why, as I cannot use username and password in the ssh command, I need a rsa key for the user that execute exec commands in php.

But may be I missed something. :-)

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: September 30, 2014 11:53AM

Maybe you should read this page in the PHP Manual ssh2_auth_pubkey_file

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: SSH key for Apache user
Posted by: OlivierP (192.198.151.---)
Date: September 30, 2014 11:55AM

I read it, but I have problems to install php_ssh2. :'-(

Options: ReplyQuote


Sorry, only registered users may post in this forum.