php -v

在OS X系统中php访问sftp时需要ssh2扩展的安装

 

brew install homebrew/php/php55-ssh2

 在OS X系统中php访问sftp时需要ssh2扩展的安装

 

【实现方式】

<?php
$connection = ssh2_connect('192.168.0.145', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, '/usr/local/bin/php -i');
stream_set_blocking( $stream, true );
echo (stream_get_contents($stream));

$stream = ssh2_exec($connection, 'ls');
stream_set_blocking( $stream, true );
echo (stream_get_contents($stream));

?>

 

 

 

相关文章:

  • 2021-08-20
  • 2021-06-27
  • 2021-09-12
  • 2021-07-12
  • 2021-09-15
  • 2021-12-18
  • 2021-07-30
  • 2021-09-17
猜你喜欢
  • 2021-04-12
  • 2021-07-21
  • 2021-07-11
  • 2021-09-13
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案