服务器的连接
$connection=ssh2_connect($host, $port);
if( ssh2_auth_pubkey_file($connection, $send_account,
$file.'/id_dsa.pub',
$file.'/id_dsa')) {
echo "Public Key Authentication Successful\n";
}
//初始化 SFTP
$resSFTP = ssh2_sftp($connection);
//下载文件
$filename = APPLICATION_PATH . '/../data/edi/upload/1'.time().'.txt';
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>60,
)
);
$context = stream_context_create($opts);
$strData = file_get_contents("ssh2.sftp://{$resSFTP}//downloadAmazonConnectivityTest", false, $context);
file_put_contents($filename, $strData);
//上传文件
$re = copy(APPLICATION_PATH . '/../data/edi/YourConnectivityTest', "ssh2.sftp://{$resSFTP}/upload/1.txt" );