Questions tagged [ssh2-exec]

PHP function to execute a command on a remote server using ssh protocol.

function to execute a command on a remote server using ssh protocol.

71 questions
1
vote
3 answers

Passing PHP variable to remote bash script

Is there a method similar to PHP's GET for bash scripts? This is what I'm trying to do... PHP file sets a variable and executes a remote bash script, the variable gets passed and is used in the bash script. So this is my PHP script...
Grant
  • 1,297
  • 2
  • 16
  • 39
1
vote
1 answer

PHP SSH2 Exec - Getting PID

How I can get PID for a process executed via SSH2. What I have tried : ssh2_exec($SSH2, 'echo `ps aux | grep -F "' . $StartCommand . '" | grep -v -F "grep" | awk \'{ print $2 }\'`'); and ssh2_exec($SSH2, $StartCommand.' > /dev/null 2>&1 & echo…
Miljan Ilic
  • 235
  • 3
  • 13
1
vote
0 answers

Execute find command through ssh2_exec in php & get results

I am using php to execute a find command in linux for search a file in a directory and copy it into a other directory. My php code is :-
Gitesh Purbia
  • 1,094
  • 1
  • 12
  • 26
1
vote
1 answer

having trouble unzipping with php / ssh2_connect

I'm trying to implement php in combination with ssh2_connect in order to unzip on a remote folder by using this script: $connection = ssh2_connect($ipaddress, 22); if (!$connection) { throw new Exception("Could not connect to…
quibuz
  • 41
  • 1
  • 5
1
vote
1 answer

Error running ruby script and use gems using ssh2 of php from remote server

I have a server on which ruby and basic gems sets like mysql2, capistrano is installed and I am trying to trigger my ruby script from a remote server (PHP server) using SSH2. My script is running all OK on the ruby server but when I try the same…
Arihant Godha
  • 2,339
  • 2
  • 26
  • 50
1
vote
2 answers

Cygwin OpenSSH server does not respond after first command from PHP (Using phpseclib)

I got cygwin and sshd working fine. And there are no issues at all when using putty. It responds as expected even for multiple commands. But when using phpseclib , A response is received only for the first command. Subsequent commands are giving a…
Chaitanya
  • 13
  • 3
1
vote
1 answer

PHP SSH session is not killed

When we use ssh2_connect, ssh session is created. After all the work is done, I do ssh2_exec($con, 'exit;'); unset($con); This is a continuous process (ssh connections are established and closed from code). After 2/3 days I find, further ssh…
Kamal
  • 31
  • 4
1
vote
2 answers

PHP: Execute Server Commands To Remote Host

I'm new to the PHP world but wanting to set up a relatively simple PHP script that will execute shell commands to a remote host via ssh2_exec when a user presses a button on the web page. I'd like this to be processed via POST as opposed to GET. I…
daniel
  • 103
  • 1
  • 2
  • 7
0
votes
0 answers

Passing a qsub command thru ssh2_exec in PHP

I have a problem with putting a "qsub" command via "ssh2_exec" in PHP. when i am running a simple test it works very well: require_once('/apps/phpPackages/vendor/autoload.php'); use phpseclib3\Net\SSH2; $ssh=new SSH2('xxxxxxxxx'); if…
0
votes
0 answers

PHP SSH2 Connection, ssh2_exec does not seem to support Executing dirname(__DIR__) or $_SERVER['DOCUMENT_ROOT'] on Remote Server

I been trying for hours to get the name of the public folder on a remote server using an ssh2 connection. On some servers the public directory is "public_html" but others may be "htdocs". I don't want to hard code the name in my code, much better to…
Jim Dandy BOA
  • 533
  • 7
  • 13
0
votes
0 answers

SSH2_Exec takes way too long to execute commands. - PHP

I am trying to execute a command on my VPS using SSH2, but for some reason, the first command always takes around 10 seconds to execute. The wierd part is that the rest of the commands, after the first one, get executed instantly after those 10…
Daniel
  • 11
  • 1
  • 1
0
votes
2 answers

How to abort a process with promise?

I am currently developping a application in Node-js to launch process throught ssh2. So i use two librairies. Th first one is ssh2 and the second is ssh2-promise. The issue is how I can send an abort signal to my process. I don't understand how I…
qLenglet
  • 1
  • 1
0
votes
1 answer

Having trouble with PHP-SSH2 connecting to remote server

I am attempting to write my first ever PHP script, and I am struggling quite a bit, the main issue is the connection/exec part is not working and instead throwing the "Could not connect to server" message... tried changing the code if…
0
votes
0 answers

Truncated Output from Nodejs ssh2-exec

Can someone please help me understand why the ssh command output is getting truncated when using result[ip] = data.toString(); but not console.log(data.toString());? I only get the first 50 bytes or so for the object assignment, but console.log gets…
Mitch
  • 130
  • 1
  • 7
0
votes
3 answers

PHP Long Running Script timeout

I am creating a page that executes a shell script on a remote server to scan a website and outputs the results on the screen. The output can sometimes take awhile to get depending on the size of the site being scanned. Currently the script works and…
WiththeWind
  • 153
  • 1
  • 9