简体   繁体   中英

How do I connect to GoDaddy's FTP server which has only a username and no password?

I am trying to download a zip file from GoDaddy's ftp server with node-ftp, but node-ftp changes empty passwords to 'anonymous@' by default in their connect function. How can I connect to their FTP server using only a username and no password?

Scanned the source code, they change the password to anonymous@ here: https://github.com/mscdex/node-ftp/blob/master/lib/connection.js#L92

const FTPClient = require('ftp');
const fs = require('fs');
const extract = require('extract-zip');

let getGoDaddyAuctionListings = () => {

    let config = {
        directory: "/tmp/",
        file: "auctions_ending_today.json.zip"
    };
    config.filePath = config.directory + config.file;
    let c = new FTPClient();

    c.on('ready', () => {
        c.get(config.file, (err, stream) => {
            if (err) throw err; //todo: change to handleError function
            stream.once('close', () => { c.end(); });
            stream.pipe(fs.createWriteStream(config.filePath));
            extract(config.filePath, {dir:config.dir}, (err) => {
               if (err) throw err;
            });
        })
    });

    c.connect({
        host: 'ftp.godaddy.com',
        user: 'auctions',
        password: ' '
    });

};

getGoDaddyAuctionListings();
> node godaddyAuctions.js

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: Login incorrect.
    at makeError (C:\Users\jim\pbn-finder\node_modules\ftp\lib\connection.js:1067:13)
    at Parser.<anonymous> (C:\Users\jim\pbn-finder\node_modules\ftp\lib\connection.js:113:25)
    at Parser.emit (events.js:189:13)
    at Parser._write (C:\Users\jim\pbn-finder\node_modules\ftp\lib\parser.js:59:10)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at Parser.Writable.write (_stream_writable.js:299:11)
    at Socket.ondata (C:\Users\jim\pbn-finder\node_modules\ftp\lib\connection.js:273:20)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:288:12)
Emitted 'error' event at:
    at Object.reentry [as cb] (C:\Users\jim\pbn-finder\node_modules\ftp\lib\connection.js:192:14)
    at Parser.<anonymous> (C:\Users\jim\pbn-finder\node_modules\ftp\lib\connection.js:113:22)
    at Parser.emit (events.js:189:13)
    [... lines matching original stack trace ...]
    at addChunk (_stream_readable.js:288:12)

This code:

this.options.password = options.password ||
    options.password === '' ? options.password : 'anonymous@';

allows an empty password, but you are not giving it an empty one:

password: ' '

You've set the password to a space. Do this:

password: ''

and it should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM