SFTP を使用してファイルをアップロードする関数と、SCP を使用してファイルをアップロードする関数の 2 つの関数を作成する必要があります。私はphpseclibとput
メソッドを使用しています。SFTP機能は完了していると思います。
今、私はSCP機能をやろうとしています。http://adomas.eu/phpseclib-for-ssh-and-scp-connections-with-php-for-managing-remote-server-and-data-exchange/ごとに、次のものが必要なようですすること:
In case of SCP:
1. Including the needed file: include('/path/to/needed/file/Net/SFTP.php');
2. Creating object and making connection:
$sftp = new Net_SFTP('host');
if (!$sftp->login('user', 'password')) { exit('Login Failed'); }
3. Reading contents of a file: $contents=$sftp->get('/file/on/remote/host.txt');
4. Copying file over sftp with php from remote to local host: $sftp->get('/file/on/remote/host.txt', '/file/on/local/host.txt');
5. Copying file over sftp with php from local to remote host: $sftp->put('/file/on/remote/host.txt', '/file/on/local/host.txt');
6. Writing contents to remote file: $sftp->get('/file/on/remote/host.txt', 'contents to write');
#5 を行う必要がありますが、これは SFTP で行ったことと似ています。SFTP と SCP は同じではありませんよね? 同じコードは正しいですか?そうでない場合、どうすれば SCP を実行できますか?