Score:0

Download FTP directory and files in remote Ubuntu server via SSH

cn flag

I want to download the files listed in a FTP directory, ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/. On my WINDOWS laptop when I put this link in the address bar of file explorer, I am able to view and download its content as shown below,

enter image description here

But I want to download these files in a remote UBUNTU server via ssh and have tried the following with corresponding error message,

  1. Both wget -r ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/ and wget -m ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/ gives the following error
--2021-08-24 09:18:07--  ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/
           => ‘ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/.listing’
Resolving ftp.ivc.polytech.univ-nantes.fr (ftp.ivc.polytech.univ-nantes.fr)... 193.52.82.2
Connecting to ftp.ivc.polytech.univ-nantes.fr (ftp.ivc.polytech.univ-nantes.fr)|193.52.82.2|:21... connected.
Logging in as anonymous ...
Error in server response, closing control connection.
Retrying.

A more detailed error report using wget -r -v -d ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/ gives the following error report,

DEBUG output created by Wget 1.17.1 on linux-gnu.
Reading HSTS entries from /usr2/mohilamb/.wget-hsts
URI encoding = ‘UTF-8’
Using ‘ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/.listing’ as listing tmp file.
--2021-08-24 15:13:32--  ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/
           => ‘ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/.listing’
Resolving ftp.ivc.polytech.univ-nantes.fr (ftp.ivc.polytech.univ-nantes.fr)... 193.52.82.2
Caching ftp.ivc.polytech.univ-nantes.fr => 193.52.82.2
Connecting to ftp.ivc.polytech.univ-nantes.fr (ftp.ivc.polytech.univ-nantes.fr)|193.52.82.2|:21... connected.
Created socket 3.
Releasing 0x00005608710e8320 (new refcount 1).
220 FTP server ready
Logging in as anonymous ...
--> USER anonymous


Error in server response, closing control connection.
Closed fd 3
Retrying.

--2021-08-24 15:13:34--  ftp://ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/
  (try: 2) => ‘ftp.ivc.polytech.univ-nantes.fr/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/.listing’
Found ftp.ivc.polytech.univ-nantes.fr in host_name_addresses_map (0x5608710e8320)
Connecting to ftp.ivc.polytech.univ-nantes.fr (ftp.ivc.polytech.univ-nantes.fr)|193.52.82.2|:21... connected.
Created socket 3.
Releasing 0x00005608710e8320 (new refcount 1).
220 FTP server ready
Logging in as anonymous ...
--> USER anonymous


Error in server response, closing control connection.
Closed fd 3
Retrying.
  1. I even tried ftp and sftp and they also do not work.

Interestingly if I execute it on Google Colab I am able to download the ftp directory. But for my remote Ubuntu system I get the above-mentioned errors. Note that one does not require username or password to access it.

raj avatar
cn flag
raj
It is possible that the FTP server may restrict the IP addresses from which login is allowed. Or your Ubuntu server may be behind a firewall that restricts FTP traffic. On my home Ubuntu computer, I was able to execute your `wget` command successfully, so it looks to me more like a networking issue.
Score:0
cn flag

If ssh is enabled, and you know the path then it should be simple to do from either of the hosts.

scp [email protected]:/ftp_root_folder/NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/. /home/someUser/DestinationFolder/

If scp is not available.

ftp
open ftp.ivc.polytech.univ-nantes.fr
cd /NAMA3DS1_COSPAD1/Avi_videos/HRC_00_Reference/
lcd ~/MyLocalPath/
pull *

I just tried this on your host, and it worked You might need to enable passive mode with pasv

raj avatar
cn flag
raj
Did you actually try to login to the host where the OP wanted to run the command (how? he didn't give us neither IP address nor credentials) and tried **from there**? Because the problem seems to be FTP connection failing **from that particular machine**...
Mohit Lamba avatar
cn flag
@Ben As i have already mentioned in the question, the ftp command you suggest does not work on my remote Ubuntu. I agree with Raj that seems to be a firewall issue. But how to detect this and want changes should i make to enable this.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.