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)); ?>
时间: 2024-12-17 07:14:32