1 頁 (共 1 頁)

sftp

發表於 : 2019-07-25 20:52:09
yehlu
https://www.php.net/manual/en/function. ... p-send.php

代碼: 選擇全部

$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644);
PHP Warning: ssh2_scp_send(): Failure creating remote file: (null) in /home/yehlu/1.php on line 6

https://stackoverflow.com/questions/957 ... -with-sftp

代碼: 選擇全部

include('Net/SFTP.php');

$sftp = new Net_SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

$sftp->put('remote.ext', 'local.ext', NET_SFTP_LOCAL_FILE);

Re: sftp

發表於 : 2019-07-25 20:53:00
yehlu
https://github.com/phpseclib/phpseclib

代碼: 選擇全部

composer require phpseclib/phpseclib
http://phpseclib.sourceforge.net/2.0.html

代碼: 選擇全部

include 'autoload.php';

$loader = new \Composer\Autoload\ClassLoader();
$loader->addPsr4('phpseclib\\', __DIR__ . '/path/to/phpseclib2.0');
$loader->register();

use phpseclib\Crypt\RSA;
use phpseclib\Net\SSH2;

$key = new RSA();
$key->loadKey(file_get_contents('private-key.txt'));

// Domain can be an IP too
$ssh = new SSH2('www.domain.tld');
if (!$ssh->login('username', $key)) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');

Re: sftp

發表於 : 2019-07-25 21:00:17
yehlu
composer require phpseclib/phpseclib
Using version ^2.0 for phpseclib/phpseclib
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing phpseclib/phpseclib (2.0.21): Downloading (100%)
phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.)
phpseclib/phpseclib suggests installing ext-mcrypt (Install the Mcrypt extension in order to speed up a few other cryptographic operations.)
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Package manifest generated successfully.

代碼: 選擇全部

sudo apt-get install php-mcrypt
sudo apt-get install php-gmp

代碼: 選擇全部

sudo apt-get install php-pear php-dev libsodium-dev
pecl install libsodium

解决configure: WARNING: You will need re2c 0.13.4 or later

發表於 : 2019-07-25 21:02:35
yehlu
https://www.phpsong.com/2220.html

我在安装rabbitmq php扩展的时候发现

configure: WARNING: You will need re2c 0.13.4 or later

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
于是百度找解决方法

wget https://sourceforge.net/projects/re2c/f ... .16.tar.gz
tar zxf re2c-0.16.tar.gz && cd re2c-0.16
./configure
make && make install

Re: sftp

發表於 : 2019-07-25 21:05:09
yehlu
Installing '/usr/lib/php/20151012/sodium.so'
install ok: channel://pecl.php.net/libsodium-2.0.21
configuration option "php_ini" is not set to php.ini location
You should add "extension=sodium.so" to php.ini

Re: sftp

發表於 : 2019-07-25 21:09:35
yehlu