Find the answer to your Linux question:
Results 1 to 6 of 6
does anyone know of a php script or even a cgi that will alow one to use ssh through apache? ie pass commands to an unprivlaged user? should be pretty ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru kkubasik's Avatar
    Join Date
    Mar 2004
    Location
    Lat: 39:03:51N Lon: 77:14:37W
    Posts
    2,396

    PHP ssh app


    does anyone know of a php script or even a cgi that will alow one to use ssh through apache? ie pass commands to an unprivlaged user? should be pretty simple, but I wasnt sure if perhaps there was a RA program somewhat liek phpbb (ie a collection of pages that will handle all those needs)
    Avoid the Gates of Hell. Use Linux
    A Penny for your Thoughts

    Formerly Known as qub333

  2. #2
    Just Joined!
    Join Date
    Oct 2004
    Location
    Newport News, VA
    Posts
    14
    i havent messed with php in a long time as im a perl guy, however it does implement a system (or the like) function i remember. with that in mind you can do something like this:

    $foo = system("ssh user\@host /path/to/command");

    print "$foo\n";

    this probably isnt valid php code, but it should get you started. this also assumes you have setup passwordless access for the user using ssh keys.

    note also that this is generally considered a bad idea as its a huge security hole. its better to write a script to be called from php on the local machine to do this for you and have the command and arguments hardcoded as to avoid possible exploits and call that local script through the system command and return its output.

  3. #3
    Linux Guru kkubasik's Avatar
    Join Date
    Mar 2004
    Location
    Lat: 39:03:51N Lon: 77:14:37W
    Posts
    2,396
    no doubt, the security problems would be massive with somethign that just passed commands, thats why I was asking if anyone perhaps knew of a collection of scripts or summin that could handle this (like phpbb or squirrelmail) no worries, im not really concerned bout it, was just a thought, just when I get stuck at places with port 22 closed (annoyning as hell) RA might be nice through a web interface over port 80, but w/e.
    Avoid the Gates of Hell. Use Linux
    A Penny for your Thoughts

    Formerly Known as qub333

  4. #4
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    how bout
    http://products.visualj.net/perlnet/
    http://www.jscape.com/sshfactory/
    http://www.indexsoft.com/siteup/

    some free, some not. not sure if thats what you were looking for or not (links came from www.hotscripts.com)

  5. #5
    Linux Guru kkubasik's Avatar
    Join Date
    Mar 2004
    Location
    Lat: 39:03:51N Lon: 77:14:37W
    Posts
    2,396
    seems like its in the right ballpark, Ill play with some of it, but in the end, I think I might just serve a java applet that has a ssh client (something like the realvnc viewer server) thanks for the input!
    Avoid the Gates of Hell. Use Linux
    A Penny for your Thoughts

    Formerly Known as qub333

  6. #6
    Just Joined!
    Join Date
    Jul 2007
    Posts
    1

    Arrow Elegant way to do SSH in PHP

    There's a very elegant way, using the ssh2.so module in PHP. A thorough article on how to set this up:
    TechBlog - How to: Make SSH connections with PHP

    It's got some source code examples as well.

Posting Permissions

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