I'm trying to set up a ssh
connection, and later a sftp
connection to transfer file via FTP to my server. I have used FileZilla to upload files successfully before.
These are my login terminal command and FileZilla login information:
ssh b0xxxxx@linux7.aa.bb.cc.dd
Host: sftp://linux7.aa.bb.cc.dd
Username: b0xx
Port: 22
Here is my 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!
";
if (ssh2_auth_password($connection, $ftp_user, $ftp_pass)) {
echo "Successful
";
} else {
die ('Failed...');
}
$sftp = ssh2_sftp($connection);
ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644);
?>
Question 1: Can I just use ftp
functions to upload/download file from my server?
Or do I must set up ssh
?
Question 2: When I execute the code, the website only displays
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
which means that the code does not execute connection
successfully. Does anyone know the cause of the bug?
Very much appreciate the help.