简体   繁体   English

使用PHP中的SSH连接到远程服务器

[英]Connect to remote server using ssh in php

I want to connect to remote server and execute some commands. 我想连接到远程服务器并执行一些命令。 The server is running in Ubuntu and I am working on Windows. 该服务器正在Ubuntu中运行,而我正在Windows上工作。 I am trying to implement ssh. 我正在尝试实现ssh。 But the connection is not working. 但是连接不起作用。 Its my first time to work with ssh. 这是我第一次使用ssh。 I have searched a lot and after downloaded the required dll files from PECL and added to php/ext path. 我进行了很多搜索,然后从PECL下载了所需的dll文件并添加到了php/ext路径中。 Also enabled the dll in php.ini file. 还启用了php.ini文件中的dll。 But the code is not working. 但是代码不起作用。 It throws an error like Fatal error: Uncaught Error: Call to undefined function ssh2_connect() 它引发类似Fatal error: Uncaught Error: Call to undefined function ssh2_connect()

<?php 
  $connection = ssh2_connect('xxx.xxx.xxx.xx', 22);
 if (!$connection) die('Connection failed');
?>

在此处输入图片说明

在此处输入图片说明

I have already added the extension in php.ini, but when I try to print the phpinfo(), it shows nothing about ssh2 extension. 我已经在php.ini中添加了扩展名,但是当我尝试打印phpinfo()时,它没有显示关于ssh2扩展名的信息。

libssh2.dllxampp/php文件夹移至system32并可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM