NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

matt271's avatar
matt271
Aspirant
Jan 13, 2013

FTP Problem

Hi, I am new to the forums and I have not long purchased my first ReadyNas, it's an NV+ V2. I must say that I absolutely love this device.

(I hope I have posted this in the right forum)

The problem I am having is that I can't get my webhosting (cPanel) to connect via ftp. However if I open filezilla I can connect with exactly the same credentials, Locally and Externally.

I use the following php script to initiate a full cpanel backup then it should save that backup on the ReadyNas:-

<?php
// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.


// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access
$cpuser = "*****"; // Username used to login to CPanel
$cppass = "*******"; // Password used to login to CPanel
$domain = "*****"; // Domain name where CPanel is run
$skin = "x3"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme

// Info required for FTP host
$ftpuser = "*****"; // Username for FTP account
$ftppass = "******"; // Password for FTP account
$ftphost = "*.***.**.***"; // Full hostname or IP address for FTP host
$ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)
$ftpport = "21"; // Port (default = 21)
$rdir = "/Web/AutoBackup"; // Remote dir (defaut = / )

// Notification information
$notifyemail = "*****.********@gmail.com"; // Email address to send results

// Secure or non-secure mode
$secure = 1; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP

// Set to 1 to have web page result appear in your cron log
$debug = 0;

// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
if ($secure) {
$url = "ssl://".$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}
$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection… Bailing out!\n"; exit; }

// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);
$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftprdir&submit=Generate Backup";

// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");

// Grab response even if we don't do anything with it.
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}
fclose($socket);
?>


I have tried both passive and active FTP transfer in this script. The backup completes successfully, however I get the following error when it trys to connect to the ReadyNas:-

Net::FTP>>> Net::FTP(2.77)
Net::FTP>>> Exporter(5.58)
Net::FTP>>> Net::Cmd(2.29)
Net::FTP>>> IO::Socket::INET(1.31)
Net::FTP>>> IO::Socket(1.29)
Net::FTP>>> IO::Handle(1.25)
Net::FTP=GLOB(0x124e6f0)<<< 220 ProFTPD 1.3.3c Server ready.
Net::FTP=GLOB(0x124e6f0)>>> USER *****
Net::FTP=GLOB(0x124e6f0)<<< 331 Password required for *****
Net::FTP=GLOB(0x124e6f0)>>> PASS ....
Net::FTP=GLOB(0x124e6f0)<<< 530 Login incorrect.
Net::FTP=GLOB(0x124e6f0)>>> TYPE I
Net::FTP=GLOB(0x124e6f0)<<< 200 Type set to I
Net::FTP=GLOB(0x124e6f0)>>> CWD /Web/AutoBackup
Net::FTP=GLOB(0x124e6f0)<<< 530 Please login with USER and PASS
Net::FTP=GLOB(0x124e6f0)>>> ALLO 220351049
Net::FTP=GLOB(0x124e6f0)<<< 530 Please login with USER and PASS
Net::FTP=GLOB(0x124e6f0)>>> PASV
Net::FTP=GLOB(0x124e6f0)<<< 530 Please login with USER and PASS
Net::FTP=GLOB(0x124e6f0)>>> QUIT
Net::FTP=GLOB(0x124e6f0)<<< 221 Goodbye.


I have checked and triple checked the password is correct, and I have also manually logged into the ReadyNas via the FileZilla FTP client and this connects without a problem. I can add files and delete files etc, so I don't think it is a permissions problem.

Any ideas or help would be greatly appreciated.

Thanks in advance Matt

1 Reply

  • Just a quick update, I was able to remedy this problem by using dyndns and setting up some port forwarding rules alongside some firewall rules. The ip address I previously used is not the WAN address, I think it must be something assigned by Netgear ReadyNas Remote. Although manual FTP worked.

    This script may help anybody else wishing to achieve the same thing. (cPanel backups to remote Nas) please feel free to use it as it is readily available on the web with a quick google search.

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More