0

The php code is:

system('ssh');

And the error information is:

'ssh' is not recognized as an internal or external command, operable program or batch file.

However when I run ssh in cmd,the ssh command is available:

image

So how can I excute ssh command in php by system()?

jww
  • 97,681
  • 90
  • 411
  • 885
yg lin
  • 115
  • 9

1 Answers1

0

It seems like the ssh executable is not in the path variable. Try to add the ssh.exe to the environment as described here: https://stackoverflow.com/a/41895179/251719

netblognet
  • 1,951
  • 2
  • 20
  • 46
  • But the ssh command is avaiable in cmd。There is an image in the question – yg lin Jul 29 '19 at 07:15
  • There is a difference between the path variable for the user and the system-wide path variable. If ssh added itself to the user path variable then it might be only available for you in the CMD, but not for other users. I assume that PHP runs with a different user account. So please check, that ssh is known via the system-wide path variable. https://www.computerhope.com/issues/ch000549.htm – netblognet Jul 30 '19 at 08:56
  • I added C:\Windows\System32\OpenSSH to my system path. But the ssh still can not work by php system('ssh').The error mesage is >'ssh' is not recognized as an internal or external command, operable program or batch file. – yg lin Aug 01 '19 at 09:48