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
0
votes
0 answers

get screen id via ssh in php

I am trying to run a lengthy command from a remote server on php using screen, but i want to make sure that the screen is killed at the end of the command. So i am trying to use "echo $STY" to get the screen id and kill it that way. for some reason,…
Bobert1234
  • 130
  • 12
0
votes
1 answer

How to convert object class into string

How can I convert the following object into string: $ssh->exec('tail -1 /var/log/playlog.csv'); So I can parse the string as the first parameter in strripos(): if($idx = strripos($ssh,','))//Get the last index of ',' substring { $ErrorCode =…
Kai
  • 93
  • 2
  • 8
0
votes
0 answers

Use ssh2_exec() to extract a tar file in the "/" directory of a remote server

Am trying to extract a .tar file in the "/" directory of a remote server (server2), using the ssh2_exec() function from a php file located in another server (server1). php file in server1:
gouyez
  • 93
  • 1
  • 2
  • 7
0
votes
0 answers

Create a txt file with content on a remote location using PHP SSH2

I try to create per PHP SSH2 an txt file with content. This is the code I tried: include('Net/SSH2.php'); $ssh = new Net_SSH2('MYIP'); if (!$ssh->login('root', 'MYPASS')) { exit('Login Failed'); } if($ssh->exec('cd /var/test/')){ echo…
Mann87
  • 314
  • 1
  • 4
  • 14
0
votes
0 answers

Executing scripts in order using PHP and MySQL

I have a website that lets user select test scripts from radio buttons, and after submitting the desired test to the remote server, using PHP: It inserts sends a row into MySQL database in the test_activity_log table, with id, username, test name,…
tiger_groove
  • 956
  • 2
  • 17
  • 46
0
votes
1 answer

Include php mail headers in ssh2 mailing function. Sending emails in html format using ssh2

So I am sending emails using ssh2 login('user', 'password')) { exit('Login Failed'); } $command = "echo…
J.Cole
  • 3
  • 1
0
votes
1 answer

I want to kill the command process without closing the command prompt/putty

**I want to kill the process of the 'trai' command without closing the putty/command prompt OR how can I run the same command in background process OR where to pass 'CTRL+C' command in this code so that it will exitthe command ** var Client =…
node mail
  • 1
  • 1
  • 2
0
votes
2 answers

PHP Net_SSH2 cannot conect

I am trying to use Net_SSH2 class for login in ssh server and i get error: Notice: No compatible server to client encryption algorithms found in /var/www/html/includes/classes/Net/SSH2.php on line 1389 Code in line 1389 was: $decrypt =…
0
votes
2 answers

Run some Linux command in PHP trail together

I wrote some php code that connected to vps through ssh I know ssh2_exec can do it, but if I want run many command like: ssh2_exec($connection, 'cd /home/ubuntu/'); ssh2_exec($connection, 'mkdir folder'); ssh2_exec($connection, 'cd…
mahdi
  • 31
  • 6
0
votes
0 answers

PHP Warning: Module 'ssh2' already loaded in Unknown on line 0

This machine was working perfectly but for some reason now I can no longer execute bash scripts remotely on this server. I can connect via ssh2_exec without issue, but when I try to run a bash script nothing happens. if…
Grant
  • 1,297
  • 2
  • 16
  • 39
0
votes
1 answer

SSH2_EXEC() Command failed

I have successed connected and authorized via ssh2 functions. But I can't exec command via ssh2_exec() function. Notoriously get this error: ssh2_exec(): Unable to request command execution on remote host I was trying pass '/bin/ls' 'ls -l' nothing…
Wojtek B
  • 160
  • 1
  • 12
0
votes
1 answer

NVM installation per user is not working with automated ssh logins

Normally when I login to my server via putty, I am able to use nvm, grunt, gulp commands but if I connect with php's ssh2 extension or with sshpass through a bash script those commands are not working unless if I execute this commands…
mirza
  • 5,685
  • 10
  • 43
  • 73
0
votes
1 answer

Remote Connection from the ssh2_exec to another remote and access to shell of new connection

i Have already connected to a remote server using ssh2-connect , and i am using ssh2_exec to run this command "sshpass -p 'xxxx1248' ssh XX@1x2.1xx.3x.xx " , now if i connected to new remote server i want to access their shell. i have a task to run…
Amey Damle
  • 69
  • 1
  • 6
0
votes
1 answer

Why commands with ssh2_exec do not end?

I have a problem running a command on my server remotely with ssh2_exec. When I use wget or unzip, the command should execute but I get no result or only a few files. What I need to know is how I can be sure that my ssh2_exec script will execute…
SarahG
  • 1
  • 3
0
votes
1 answer

php ssh2_exec not executing java command

Below code is not able to get the Java version using ssh2_exec, I have tried absolute path /usr/bin/java as well, same code is working with 'php --version', what could the possible reason for this issue? Already done chmod 777 for /usr/bin/java …
siso
  • 265
  • 1
  • 7
  • 20