Rclone FTPS
Rclone is a software primarily used with cloud storage providers; however, it is also an easy-to-use command-line download manager for many protocols, including FTP/FTPS/SFTP. We will show you how to install Rclone onto a Linux machine on your local network and how to set up automatic downloading from your Ultra.cc service.
Prerequisites
- A host machine on your home/local network running a Linux distribution
- A regular user account with
sudoprivileges curl,screen, andflockavailable on the host
macOS may also work, but it is outside the scope of this guide.
Install Rclone on Host Machine
Log in to your host machine as a regular user with sudo privileges. Use elevated privileges only for installation; configure and run Rclone as your regular user.
- Run the official Rclone installation command:
sudo -v ; curl https://rclone.org/install.sh | sudo bash- If
curlis not installed, install it using your distribution's package manager. On Debian or Ubuntu, run:
sudo apt-get update && sudo apt-get install curl -y- After installation, remain logged in as your regular user for the configuration steps below.
Configure Rclone FTP Remote
The first step is to invoke the rclone config menu with the following command.
rclone config- This will present a list of options
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q\\>- Press
Nthen ENTER to configure a new remote. - Now enter a name. You will need this later when writing the automated script.
- You will be presented with a list of storage types. Enter
ftp, or select the number currently shown for FTP. Provider numbers can change between Rclone versions.
Field | Value |
Host | Your Ultra Address (servername.usbx.me) or IP (185.123.123.123) |
User | Your Ultra Username |
Port | Port 21 is standard. You can press Enter |
FTP password | Press Y, then enter your FTP Password. You will be asked for this twice. |
Use FTPS over TLS (Implicit) | False |
Use FTP over TLS (Explicit) | True |
Edit advanced config? (y/n) | Press Y |
Maximum number of FTP simultaneous connections, 0 for unlimited | Press enter |
no_check_certificate | False |
Disable using EPSV even if server advertises support | Press Enter |
Enter a encoder.MultiEncoder value. Press Enter for the default ("Slash,Del,Ctl,RightSpace,Dot"). | Press Enter |
y) Yes this is OK (default) | Press Y to complete the rclone configuration |
Test Remote Access
- Once the configuration of the remote is completed, it is a relatively simple job to check if all is configured correctly.
- The below command will list all directories in the home directory of your Ultra service.
- Replace
remotewith the name you selected for your remote.
rclone lsd remote:Automate downloading from Ultra.cc
- Our first step is to write a simple script. We will set up a
lockfolder for a file lock system so the script will not run if it is already running. - Create the lock folder with the following command.
mkdir -p ~/lock- Next, create the automated download script by opening the text editor with the following command.
nano rclone-ftp.sh- Paste the following lines into it:
- Make sure to replace
remotewith the name you selected for your remote. - Make sure to replace
ultrafoldertocopyto match the folder you wish to download. - Also, replace
$HOME/pathtosavefileswith the local destination directory.
#!/bin/bash
exec {lock_fd}>"$HOME/lock/FTPLOCK" || exit 1
flock -n "$lock_fd" || { echo "ERROR: flock() failed." >&2; exit 1; }
if [ -z "$STY" ]; then exec screen -dm -S rclone-ftp /bin/bash "$0"; fi
rclone copy -v remote:/ultrafoldertocopy "$HOME/pathtosavefiles"
flock -u "$lock_fd"- Save and exit the editor by pressing
Ctrl+XthenYand ENTER. - Next, make your script executable with the following command.
chmod +x rclone-ftp.sh- The script is now ready to be executed. To do so, run the following command.
./rclone-ftp.sh- If the script is already running and you start it again, you may see “Flock Failed.” This is normal and prevents concurrent downloads. The lock is released automatically when the running process exits.
- You can also check the progress of the script, which is running in a screen session. Attach to the session with the following command.
screen -rd rclone-ftp- If all is well after the test, the script can be automated to run via crontab.
- Open crontab with the following command.
crontab -e- Inside the crontab add the following line at the bottom of the crontab file.
- The script will run at 4 AM each day, but can be reconfigured to your liking. See crontab.guru for more information.
0 4 * * * $HOME/rclone-ftp.sh- Save and exit it by pressing
Ctrl+XthenYand ENTER. - The script will now run at 4 AM each day, checking for files that have changed and syncing them to the destination folder.
If you require further assistance, you can open a support ticket here.