passing commands via ssh

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default passing commands via ssh

    Hello all,

    I am trying to execute a command on another server from my web
    application.

    I need to execute the command via ssh for security reasons. I have a
    private key/passphrase installed for ssh so that I can run ssh without a
    password.

    The command:

    ssh -i vertex vertex@wolf TX 77041 COD 10000.00

    Works from my box's command line. The vertex 'key' for ssh is also in
    the same directory.

    But when I run
    system(ssh -i vertex vertex@wolf TX 77041 COD 10000.00)
    from my script I get an error:

    Host key verification failed.

    Also, when including the return status var I get different values such
    as: 255 or 127 or 1....But I do not know what these mean.

    This may not be a php issue but a webserver issue - sorry but I have no
    ideas at this point.

    Do I need to look in to some other functions to facilitate this? I did
    try passthru() and exec() with similar results.

    Any help is as always greatly appreciated.

    Thx
    Mignon















    Mignon Hunter Guest

  2. Similar Questions and Discussions

    1. ssi commands in DW
      :confused; I'm a newbee trying to take over a Web site that just sort of grew over the years with sucession of developers. First, it works! ...
    2. Key commands
      I have very much utilized InDesigns ability to customize key commands (mine pretty much mimic Quarks since I'm already familiar with them) but I...
    3. Passing commands into flash player
      We would like to be able to Play, pause, stop, and pass variables into a flash movie from a .NET application. I think there are a few ways we can...
    4. Help with UNIX commands
      I am researching some unix commands and I would like to know if someone knows where I can find them online. I just want to know what are they used...
    5. HELP! Passing from database to asp page allowing user input then passing to another database.
      My big problem is I'm a newbie working with someone else's code.(See code below) What I want to do is for the records that have a purchase order...
  3. #2

    Default Re: [PHP] passing commands via ssh

    On Jul 9, 2003, "Mignon Hunter" claimed that:

    |Hello all,
    |
    |I am trying to execute a command on another server from my web
    |application.
    |
    |I need to execute the command via ssh for security reasons. I have a
    |private key/passphrase installed for ssh so that I can run ssh without a
    |password.
    |
    |The command:
    |
    |ssh -i vertex vertex@wolf TX 77041 COD 10000.00
    |
    |Works from my box's command line. The vertex 'key' for ssh is also in
    |the same directory.
    |
    |But when I run
    |system(ssh -i vertex vertex@wolf TX 77041 COD 10000.00)
    |from my script I get an error:
    |
    |Host key verification failed.
    |
    [snip]
    |Any help is as always greatly appreciated.
    |
    |Thx
    |Mignon

    Do you have the private key/passphrase installed as a regular user or the
    httpd user of the local machine on the remote machine?

    PHP will run the scripts as the httpd user, not as the user who owns the
    script.

    <?php
    $line = exec("/usr/bin/id");
    print ("PHP runs as $line\n</pre>\n");
    ?>

    Jeff

    --
    Registered Linux user #304026.
    "lynx -source [url]http://jharris.rallycentral.us/jharris.asc[/url] | gpg --import"
    Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED
    Responses to this message should conform to RFC 1855.



    Jeff Harris Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139