Avatar of mcgilljd
mcgilljd

asked on 

php on linux box to get files from windows server with sftp

I tried to use the below ftp script on linux box to get files from remote windows server, but it doesn't connect.

Port 22 is open on windows server for sftp.

Do I need a different method to use sftp? Or is this the right script and I just have something small wrong like a \?

Do I need to do more than open port 22?

Do I need an authentication key?

I am new to sftp, I usually use ftp.
<?php
$today = date('Ymd');
$ftp_server = '111.111.111.111';	
$remote = "E:\\remote\\logs\\Login\\Output\\OrderTransactionLog.csv";
$local = "/local/htdocs/ftp/files/filename$today.csv";
$username = "username";
$password = "password";
$c = ftp_connect($ftp_server) or die("$ftp_server\n");
ftp_login($c,$username,$password) or die("$username\n");
ftp_get($c,$local,$remote,FTP_ASCII) or die("$remote\n");
ftp_close($c);
?>

Open in new window

File Sharing SoftwarePHPSSH / Telnet Software

Avatar of undefined
Last Comment
Rob Siklos

8/22/2022 - Mon