473,503 Members | 3,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Php-html and apache user

Hi,
I'm a beginner with php and I've a problem using it from a web page.
I explain:
I need to establish an ssh connection from a web page. I've used
ssh.keygen for the authentication, that means that the user "lorenza" can
login without interactive ssh.
I've noticed that when I call a php script from a web page, it will be
executed from the "apache user".
now, the problem is that the ssh connection isn't established because the
user apache is not authorized and I've no possibility to authorize him
(administration problem).

anyone knows how can I establish an ssh connection to a remote host where
only the ssh port is opened, using php or something else, and
authenticating with a user different from apache??
Lorenza

Jul 17 '05 #1
5 3541
So you want a php script to launch an shell command, that shell command
being 'ssh', is that correct?

The apache launched process will always be owned by the apache process
unless you setuid, or use sudo to allow it to launch processes as other
users. I don't reccomend this.

You can call ssh differently. "/sbin/ssh -lusername hostname", I imagine
your trying to use your keys, correct? specify the keys also.
"/sbin/ssh -lusername -f identity hostname".

Now calling it from PHP all depends on what you want to do with it. You're
not going to be able to do interactive ssh sessions, so yo have to deciede
if you want to capture the output of your command, or just execute the
command and ignore the output. You can simulate interactivity via
http://us4.php.net/manual/en/function.proc-open.php

<?php
define('SSHCMD', '/sbin/sssh -l harrysacks -f
/home/harrysacks/.ssh/identity scrotum.org "/bin/ls /etc/hack"');
//Use popen, or backticks, your choice
$ssh = popen(SSHCMD, "r");
print fread($ssh, 4096);
pclose($ssh);
unset($ssh);
//or
$ssh = `SSHCMD`;
print $ssh;
?>

Good luck.

"Lorenza Soverini" <so******@cs.unibo.it> wrote in message
news:Pi**************************************@piso lo.cs.unibo.it...
Hi,
I'm a beginner with php and I've a problem using it from a web page.
I explain:
I need to establish an ssh connection from a web page. I've used
ssh.keygen for the authentication, that means that the user "lorenza" can
login without interactive ssh.
I've noticed that when I call a php script from a web page, it will be
executed from the "apache user".
now, the problem is that the ssh connection isn't established because the
user apache is not authorized and I've no possibility to authorize him
(administration problem).

anyone knows how can I establish an ssh connection to a remote host where
only the ssh port is opened, using php or something else, and
authenticating with a user different from apache??
Lorenza

Jul 17 '05 #2
On Mon, 27 Oct 2003 20:00:38 +0100, Lorenza Soverini wrote:
Hi,
I'm a beginner with php and I've a problem using it from a web page.
I explain:
I need to establish an ssh connection from a web page. I've used
ssh.keygen for the authentication, that means that the user "lorenza" can
login without interactive ssh.

<snip!>

Question is, why do you need to do this? There is more than one way to
solve any programming problem and there may be a solution that works
better.
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #3
Answer is:
I thought that php was a good way to do it... and I don't know another way
to do it...
any suggestion will be well accepted...
Lorenza


Question is, why do you need to do this? There is more than one way to
solve any programming problem and there may be a solution that works
better.
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/


Jul 17 '05 #4
> I thought that php was a good way to do it... and I don't know another way
to do it...
any suggestion will be well accepted...


Can you walk us thru what the object of the project is?

Expect might be the way to go if your trying to script terminal
interactions.
http://expect.nist.gov/

Jul 17 '05 #5
Hi,
first of all thanx for your answer...
I've tried to do what you said, I've seen, using Iptraf, that something
works, but not properly..
Without using -i identity it doesn't work at all, adding that it trys to
connect but the connaction isn't established.
I've tried exactly the code you write in that mail but I receive any
result.

The thing I need to do is connecting to a remote machine andh copy some
files from it...
I've even tried scp but the problem is the same, it cannot establish the
connection.

....and I really don't know why...
Lorenza

On Mon, 27 Oct 2003, it was written:
So you want a php script to launch an shell command, that shell command
being 'ssh', is that correct?

The apache launched process will always be owned by the apache process
unless you setuid, or use sudo to allow it to launch processes as other
users. I don't reccomend this.

You can call ssh differently. "/sbin/ssh -lusername hostname", I imagine
your trying to use your keys, correct? specify the keys also.
"/sbin/ssh -lusername -f identity hostname".

Now calling it from PHP all depends on what you want to do with it. You're
not going to be able to do interactive ssh sessions, so yo have to deciede
if you want to capture the output of your command, or just execute the
command and ignore the output. You can simulate interactivity via
http://us4.php.net/manual/en/function.proc-open.php

<?php
define('SSHCMD', '/sbin/sssh -l harrysacks -f
/home/harrysacks/.ssh/identity scrotum.org "/bin/ls /etc/hack"');
//Use popen, or backticks, your choice
$ssh = popen(SSHCMD, "r");
print fread($ssh, 4096);
pclose($ssh);
unset($ssh);
//or
$ssh = `SSHCMD`;
print $ssh;
?>

Good luck.

"Lorenza Soverini" <so******@cs.unibo.it> wrote in message
news:Pi**************************************@piso lo.cs.unibo.it...
Hi,
I'm a beginner with php and I've a problem using it from a web page.
I explain:
I need to establish an ssh connection from a web page. I've used
ssh.keygen for the authentication, that means that the user "lorenza" can
login without interactive ssh.
I've noticed that when I call a php script from a web page, it will be
executed from the "apache user".
now, the problem is that the ssh connection isn't established because the
user apache is not authorized and I've no possibility to authorize him
(administration problem).

anyone knows how can I establish an ssh connection to a remote host where
only the ssh port is opened, using php or something else, and
authenticating with a user different from apache??
Lorenza



Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
4575
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
7
1999
by: Timothy Madden | last post by:
Hello all I'm trying to include some files in an included file. Think of some scripts like this /index.php /scripts/logging.php /scripts/config.php /scripts/db_access.php
2
3552
by: Cox | last post by:
Hello: My address jsmith435@cox.net is subscribed to at least the PHP General mailing list. I have for days now been trying to unsubscribe from all PHP mail lists. I have followed the...
12
9134
by: comp.lang.php | last post by:
I am using CLI PHP to run a PHP script, c:\wamp\php\php.exe, but instead of executing my script, it's actually displaying the raw code instead. How can I run my code using CLI PHP? I installed...
1
3451
by: sandeepifw | last post by:
plz help I have a php variable $content on page menu.php now i wnt to use its value on page menu_items.js hear menu_items.js create a menubar.its contan both static and dynamic menu my...
10
1727
by: sickboy | last post by:
Hey everyone, I am working on a new site, ForceFedTV.com and I have gotten reports that the site runs great on mac, but once loaded on a pc, after clicking a few links then going back to the home...
0
2736
by: Benjamin Grieshaber | last post by:
Hi, I´m on SuSE 9.3 with xmlrpc-c and xmlrpc-c-devel installed (ver. 0.9.10) I tried to compile php with xmlrpc support and got the following errors: ...
15
1439
by: mike | last post by:
Hi, I am very new to PHP I am having php.ini problems. I am working in XP with IIS and have php installed as an ISAPI. I am trying to change values in my php environment like 'upload_tmp_dir',...
0
1335
by: Patriot89 | last post by:
I have a quick question in reference to php file extenstions... I have code for example like this... This is all located on this site www.ixalliance.com/BHS/Default (This is my nav.php file) ...
5
4606
Chrisjc
by: Chrisjc | last post by:
Good afternoon, I am seeking some php configuration help. Here is the run down I am running Windows server 2003 and IIS V6.0 I have never had issues before until now. I have Symantec Antivirus 11.0...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.