Re: [PHP] SSH and php

From: David T-G (davidtg-php_at_justpickone.org)
Date: 11/17/03


Date: Mon, 17 Nov 2003 11:21:29 -0500
To: PHP General list <php-general@lists.php.net>


Ryna --

...and then Ryan A said...
%
% Hey David,

Hiya!

%
% % Is it possible to run a SSH command from php?
% >Sure; it's possible to run any command from php. It may not work all
% >that well, though :-)
%
% heheh, good one. As helpful as usual :-D

Always there for ya, man :-)

%
% >Good enough. What do you want to do?
%
% Basically stop/restart apache when i make changes to the httpd.conf file.

There are ways to do that -- I personally would create a kick script
outside of the htdocs tree, give the apache user permission to run that,
and call that script from an https page with some authentication -- but
you always have to fall back to "if that script fails, then I need to log
in and use the shell" anyway.

% But then thinking of it I realize that if I stop apache from a script, once
% apache is stopped
% I cant run any php to restart it...right?

You certainly can't run any php web script :-)

% So I guess my question gets cut down to basically "any good place/program to
% learn/use SSH?"

As you've been shown, ssh is nothing magical; what you want to do is
learn how to use a *NIX shell. Think DOS command prompt. If you can
already use a command prompt, then try an ssh in and look around (ls,
chdir, pwd, ...).

HTH & HAND

:-D

-- 
David T-G                      * There is too much animal courage in 
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




Relevant Pages

  • Scripts using SSH and SSH_ASKPASS
    ... To test SSH scripts you better destroy the control TTY. ... The trick is to run YOUR script on YOUR local ... As for the password relaying command: this needs not be an X command. ... # we read one line from a temporary pipe. ...
    (comp.security.ssh)
  • Re: remote server backup script
    ... > Just type away at the command line. ... Make a backup of whatever you want ... > command line, in a script. ... >>the server ssh key on the clients machine). ...
    (comp.os.linux.misc)
  • Re: i cant call subversion from php with shell_exec()
    ... But when I put it in a PHP script ... "svn update" command never run. ... So apparently PHP does have permission to run the svn update command. ...
    (comp.lang.php)
  • HELP! Really anoying apache/php problem
    ... outcome in text files (programmed in harbour, ... run it again from the command line it works great (so i think it's no rights ... and run it like 'php test.php' it works great!, but if i include it in an ... set_time_limitin my script, ...
    (alt.php)
  • Using SSH to terminate remote systems for disaster recovery
    ... I have a need to terminate a number of AIX 5.1 systems ... from a single script. ... I can do this using ssh. ... if I issue the shutdown command from ssh, ...
    (AIX-L)