LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2012, 04:37 PM   #1
128
LQ Newbie
 
Registered: Sep 2012
Posts: 22

Rep: Reputation: 0
Arrow php execute ssh2 url command


How do command with action url ? http://some-hosting.com/ssh2.php?command=reboot

PHP Code:
<?php

// Change please adjust the following variables:

$server['ip'] = "127.0.0.1";             // Host
$server['sshport'] = 22;           // SSH Port (Standard: 22)
$server['user'] = "root";         // Username
$server['pw'] = "password";         // Password

$command "call url";             // This command is executed on the SSH server!

// Change customer from here if possible, nothing more

if($ssh ssh2_connect($server['ip'], $server['sshport'] )) {
    if(
ssh2_auth_password($ssh$server['user'], $server['pw'])) {
        
$stream ssh2_exec($ssh$command);
        
stream_set_blocking($streamtrue);
        
$data '';
        while(
$buffer fread($stream4096)) {
            
$data .= $buffer;
        }
        
fclose($stream);
        print 
$data;
     }else {
         echo 
"Error: Could not connect to the selected server, incorrect username or password..";
     }
}else {
         echo 
"Error: Could not connect to the selected server, SSH server IP or port wrong..";
}

?>
hope help me. thanks you

Last edited by 128; 09-29-2012 at 05:00 PM. Reason: url > change > action url
 
Old 09-29-2012, 05:52 PM   #2
128
LQ Newbie
 
Registered: Sep 2012
Posts: 22

Original Poster
Rep: Reputation: 0
Someone?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to execute iptables command on php? iluv8250 Programming 7 07-29-2009 12:42 PM
Execute Linux command with PHP jpostma Programming 2 06-01-2007 01:48 AM
PHP can't execute shell command ! rome Programming 3 11-15-2005 12:46 PM
PHP can't execute shell command ! rome Programming 1 11-15-2005 09:12 AM
PHP execute at command line gjmwalsh Mandriva 2 12-06-2003 01:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration