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
5
votes
1 answer

Query a remote server's operating system

I'm writing a microservice in Node.js, that runs a particular command line operation to get a specific piece of information. The service runs on multiple server, some of them on Linux, some on Windows. I'm using ssh2-exec to connect to the servers…
Rafael Sofi-zada
  • 511
  • 3
  • 14
5
votes
2 answers

feof generates infinite loop

So I do one simple thing, firstly I exec command via ssh2_exec (after success authenticate) and then read answer in variable. My code below (without authenticate) try { $stdout_stream = ssh2_exec($this->connection, $_cmd); …
3
votes
1 answer

xterm.js + ws + ssh2 not transmitting terminal resize signals (SIGWINCH) to ssh server

Rephrasing my issue here. I have a web-app using 'xterm.js', 'ws', and 'ssh2' node modules. Everything works great. Except one thing: SIGWINCH window resize signal won't make it to the sshd server, or the ssh2 stream. Other sigs, esc, ansi work…
jdmayfield
  • 1,400
  • 1
  • 14
  • 26
3
votes
2 answers

PHP : ssh2 : How to connect to a second ssh server

I have to connect to a server via ssh, but to access it I need to first connect to another ssh server. I use standard password access to them. So my steps are: ssh root@serverdomain1.com then when connected in serverdomain1 I do in terminal: ssh…
Zenslainer
  • 159
  • 1
  • 9
2
votes
1 answer

PHP ssh2 multiple commands with output

I need help with ssh2 connection to the network device. for example I need 3 commands to enter to the router: enter to the configuration mode (command: configure) add some configuration string check syntax here is my example:
2
votes
2 answers

PHP calling a listener script to run continuously

I have a website that lets user select test scripts, and after submitting the desired test, it will POST to insert.php and: It inserts sends a row into MySQL database in the with done=0 (insert.php). There is a listener script (testexe.php) that I…
tiger_groove
  • 956
  • 2
  • 17
  • 46
2
votes
1 answer

phpseclib-SSH2 -> Create an environment variable with the exec-command

I am working on a PHP-application, with which I can connect to a RaspberryPI (running Linux) via SSH2 of the phpseclib. Connecting to a device and getting information over the "ls"- oder "pwd"-commands is working fine. But now I am trying to create…
Simon
  • 23
  • 6
2
votes
1 answer

Execute a command on a remote server with PHP - no callback / stream required

I have been looking HERE to try and figure this out but I don't fully understand all of the parameters so I'll explain what I'm trying to do : I want to run the following command on a remote Linux (Ubuntu) server via PHP using an existing variable…
Grant
  • 1,297
  • 2
  • 16
  • 39
2
votes
1 answer

PHP Read linux tail -f with SSH2

I've been working on a way to display ssh output in my web browser. What I have is a shell script I've created which does a tail -f /var/log/syslog with some grep arguments. Now I wish to call this shell script and display the data returned in real…
anonamas
  • 243
  • 1
  • 6
  • 15
2
votes
1 answer

PHP Warning: ssh2_exec(): Failed setting DEBIAN_FRONTEND=noninteractive on remote end

I have written snippet to execute code in remote machine using ssh2_execand command execution works fine . I want to set some environmental variables. But when I pass them as ssh2_exec params I'm getting this warning and the environmental variables…
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
1
vote
2 answers

PHP SSH2 echo to file for stop session

I want to create a stop.sh file for stopping screen session. $test = "screen_name"; This is the command: kill -15 $(screen -ls | grep '[0-9]*\.$test' | sed -E 's/\s+([0-9]+)\..*/\1/'`) And I want to create this file with php ssh2_exec like…
1
vote
0 answers

php function ssh2_exec('unzip archiveFilename') doesn't exctract all the content of archive

All the content of the archive doesn't unzip when I use the php function ssh2_exec() There is around 10 files and 5 folders in my ziparchive and the system unzip sometimes just 3 files another time the system unzip 1 folder and 3 files.... My code…
laurent
  • 67
  • 6
1
vote
0 answers

Write formatted result from ssh2_exec on txt with php

I tried with php to write on a txt file the result of command 'df -h'. $comand = 'df -h'; $stream = ssh2_exec ( $connection, $comand ); stream_set_blocking ( $stream, true ); $stream_out = ssh2_fetch_stream ( $stream, SSH2_STREAM_STDIO…
MONS7ER
  • 124
  • 10
1
vote
1 answer

PHP or Python on windows send command to remote Linux stack

I am developing a web application to send G-Code to the 3dprinter. This 3dprinter has a Linux stack. I could make it in Ubuntu application on Win by using the following command ssh root@ip password python3 /usr/share/griffin/command_util.py …
sxj1121
  • 11
  • 2
1
vote
1 answer

Easy way to run node SS2 exec commands

I am not a expert on node usually i would try to troubleshoot and hack the thing till it works but i am short on time and need some advice using the NPM-ssh2 package i want to be able to execute a command on my customer router i just need to know…
Reyn Wouda
  • 13
  • 3
1
2 3 4 5