473,549 Members | 2,669 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 3549
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.un ibo.it> wrote in message
news:Pi******** *************** *************** @pisolo.cs.unib o.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.un ibo.it> wrote in message
news:Pi******** *************** *************** @pisolo.cs.unib o.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
4585
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 cool language. I've done Perl and like it, there are a few features of PHP I like but overall am not too excited about it. I have found PHP's...
7
2002
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
3556
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 instructions posted on the php.net web site but all my e-mails go unresponded to. I've tried contacting the webmaster as well as the admin address posted...
12
9141
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 WAMP5 on WinXP. Thanx Phil
1
3456
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 lase menu as vander is dynamic now how can i use this variable on .js my js file look like
10
1736
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 button, they claim they get all black and nothing else. I am working with an index script that incorporates php to create something like frames. ...
0
2738
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: ext/xmlrpc/.libs/xmlrpc-epi-php.o(.text+0x359): In function `set_zval_xmlrpc_type': /php-5.2.5/ext/xmlrpc/xmlrpc-epi-php.c:1313: undefined reference to...
15
1444
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', 'upload_max_filesize'. I have scanned my computer and the only php.ini file on the machine is in C:\Program Files\PHP. If I change entries in that...
0
1337
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) <div class="navstyle" id="navmenu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="administration/admin.php"...
5
4614
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 Manager, it controls all the Symantec clients in the company. Now it uses a web interface for all of its commands and settings which is called...
0
7723
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7483
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7817
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6051
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5092
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.