Php-html and apache user

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lorenza Soverini

    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

  • Brian

    #2
    Re: Php-html and apache user

    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


    <?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" <soverini@cs.un ibo.it> wrote in message
    news:Pine.LNX.4 .21.03102719560 00.31393-100000@pisolo.c s.unibo.it...[color=blue]
    > 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
    >[/color]


    Comment

    • Jeffrey Silverman

      #3
      Re: Php-html and apache user

      On Mon, 27 Oct 2003 20:00:38 +0100, Lorenza Soverini wrote:
      [color=blue]
      > 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.[/color]
      <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/

      Comment

      • Lorenza Soverini

        #4
        Re: Php-html and apache user

        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

        [color=blue]
        >
        > 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/
        >
        >[/color]

        Comment

        • Brian

          #5
          Re: Php-html and apache user

          > I thought that php was a good way to do it... and I don't know another way
          to do it...[color=blue]
          > any suggestion will be well accepted...[/color]

          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.




          Comment

          • Lorenza Soverini

            #6
            Re: Php-html and apache user

            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:
            [color=blue]
            > 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" <soverini@cs.un ibo.it> wrote in message
            > news:Pine.LNX.4 .21.03102719560 00.31393-100000@pisolo.c s.unibo.it...[color=green]
            > > 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
            > >[/color]
            >
            >
            >[/color]

            Comment

            Working...