Using PHP to set up SSH connection and SFTP -
i'm trying set ssh
connection, , later sftp
connection transfer file via ftp server. have used filezilla upload files before.
these login terminal command , filezilla login information:
ssh b0xxxxx@linux7.aa.bb.cc.dd host: sftp://linux7.aa.bb.cc.dd username: b0xx port: 22
here php
code:
<?php $ftp_server = "b0xx@linux7.aa.bb.cc.dd"; $ftp_port = 22; $ftp_user = "b0xx"; $ftp_pass = "##"; $connection = ssh2_connect($ftp_server, $ftp_port); echo "successful!\n"; if (ssh2_auth_password($connection, $ftp_user, $ftp_pass)) { echo "successful\n"; } else { die ('failed...'); } $sftp = ssh2_sftp($connection); ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644); ?>
question 1: can use ftp
functions upload/download file server? or must set ssh
?
question 2: when execute code, website displays
internal server error server encountered internal error or misconfiguration , unable complete request.
which means code not execute connection
successfully. know cause of bug?
very appreciate help.
seems ssh2 pecl extension not installed. install extension , try code.
Comments
Post a Comment