Tag: ftp

  • Ubuntu pure-ftpd reply with unroutable address

    On AWS Ubuntu server running pure-ftpd, when i try connecting, i get error

    Status:	Server sent passive reply with unroutable address. Using server address instead.
    

    To fix this, run

    echo "30000 50000" > /etc/pure-ftpd/conf/PassivePortRange
    echo "YOUR_PUBLIC_IP_HERE" > /etc/pure-ftpd/conf/ForcePassiveIP
    

    YOUR_PUBLIC_IP_HERE = Replace with your Elastic IP or Public IP (if you don’t have an Elastic IP).

    Restart pure-ftpd

    systemctl stop pure-ftpd
    systemctl start pure-ftpd
    

    On AWS security groups, you need to open following ports

    TCP 21
    TCP 30000-50000
    
  • Upload all files to FTP server using lftp

    lftp allow you to upload all files and sub folders using single command. With normal ftp command, you need to use put/mput command many times to do the same.

    To download all files from FTP server, use “mirror” command. mirror command also allow you to upload files to remote server by specifying -R (reverse mirror) option.

    This is very useful for uploading files from SSH shell account.

    For help, use ? in lftp command prompt. To get help for specific command use

    help 
    

    Exampe

    help mirror
    

    To upload all files from local folder to remote server, run

    lftp -d -u FTP_USER,FTP_PASSWORD FTP_SERVER_IP
    set ftp:ssl-allow no
    mirror -R /var/flashwebhost/vshare2.7/ public_html
    

    Following will upload vshare2.7 folder to FTP root folder.

    unzip vshare2.7.zip
    lftp -d -u FTP_USER FTP_SERVER_IP
    set ftp:ssl-allow no
    mirror -R vshare2.7
    

    See lftp

  • chmod recursive with lftp

    lftp is a command line FTP program with several advanced options.

    To chmod all files and folders inside a sub folder, you can use -R option.

    chmod -R 777 modules
    

    This will chmod all files and subfolders inside the folder “modules” to 777.

    See lftp

  • Download all files from FTP server using lftp

    lftp is a command line FTP client, that can be used to download all files from a remote FTP server to local folder.

    This is useful when you want to move migrate site from one server to another.

    To download all files from FTP server, create an empty folder and change to it.

    mkdir ~/sok-move
    cd ~/sok-move
    

    Run lftp command to connect to remove FTP server.

    lftp -u FTP_SERVER_USER,'FTP_SERVER_PW' FTP_SERVER_IP
    

    This will connect you to FTP server. Run following 2 commands as needed. First command will disable SSL, this is required if remote FTP server have no SSL installed. Second command will enable active FTP mode, will be useful if passive FTP don’t work for you.

    set ftp:ssl-allow false
    set ftp:passive-mode off
    set ssl:verify-certificate no
    

    Change the folder that you need to download and run

    mirror
    

    This will download everything from remote FTP server to your local folder.

    You can use options

    mirror -c --parallel=10
    

    Here -c is for continue, will help with resume if you get disconnected or want to mirror again.

    –parallel=10 will tell lftp to download 8 files in parallel instead of files one by one.

    See lftp

  • 500 I won’t open a connection to x.x.x.x (only to y.y.y.y)

    500 I won’t open a connection to x.x.x.x (only to y.y.y.y)

    When connecting to FTP server from a remote server hosted in Microsoft Azure i get error

    500 I won’t open a connection to x.x.x.x (only to y.y.y.y)

    This is because you are behind NAT firewall and trying to use FTP in Active mode.

    To fix the error, enable FTP passive mode with command

    passive
    

    ftp