首页 > 代码库 > 在OS X系统中php访问sftp时需要ssh2扩展的安装

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

php -v

技术分享

 

brew install homebrew/php/php55-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));

?>

 

 

 

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