Use 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 today 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
Host machine on your home/local network running a Linux distribution (Mac OS can also be used but is not in the scope of this guide; however, it may still work as a general guide)
Install Rclone on Host Machine
Installing Rclone is made incredibly easy by the developer. First login to your Host machine via SSH; this can be under a sudo
user, but it is recommended to install rclone as root
user and later set up rclone under a sudo/sub-user, never set up under root
.
- Once logged in, run this curl command
curl https://rclone.org/install.sh | sudo bash
- If you receive a message telling you that the “curl command cannot be found,” you will need to install it and run the command above again. To install curl, run
apt-get install curl -y
- Once Rclone is installed, it is recommended you switch to a new user and configure under that user. If you have not created a new user, the steps are simple. Execute the following command.
- For this guide, we will call the user
ultra
.
adduser ultra
- Follow the on-screen prompts for user information and password. Once that is completed, it is an excellent idea to promote this user to sudo; this allows for the execution of higher privileged commands, which are not required for Rclone but are certainly worth setting up.
- To add a user to sudo after creation, execute the following command.
adduser ultra sudo
- If, for some odd reason, your distro did not have sudo installed, now might be a good time to run an install just in case:
apt-get install sudo -y
- Now we can switch to our
ultra
user.
su ultra
- Type
cd
to jump to the user home folder. This isn’t strictly required but is best practice.
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
N
then ENTER to configure a new remote. - Now enter a name: you will need this later when writing our automated script.
- Now you will be presented with an extremely long list of options and at the time of writing this,
11
is FTP, but as it is a living list, the number may change in the future.
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 | True |
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 for 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
remote
with the name you selected for your remote.
rclone lsd remote:
Automate download from Ultra.cc
- Our first step is to write a simple script. We will set up a
lock
folder 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
- If you ever get a flock failed command, simply delete the lock file in
~/lock
by executingrm -rdf ~/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
remote
with the name you selected for your remote. - Make sure to replace
ultrafoldertocopy
to match the folder you wish to download. - Also, make sure to edit the
/home/ultra/pathtosavefiles
to where you want to save the files.
#!/bin/bash
exec {lock_fd}>/home/$USER/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/ultra/pathtosavefiles
flock -u "$lock_fd"
- Save and exit the editor by pressing
Ctrl+X
thenY
and ENTER. - Next, make your script executable with the following command.
chmod +x rclone-ftp.sh
- The script is now ready to be executed, and to do so, execute the following command.
./rclone-ftp.sh
- If the script is running and you were to rerun it, you may see an error message “Flock Failed” this is a file lock to stop multiple downloads running and is normal. If you are sure it isn’t running you can delete the lock file from
~/lock
. - 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.
- Make sure to replace
ultra
with the username of your system. - 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/ultra/rclone-ftp.sh
- Save and exit it by pressing
Ctrl+X
thenY
and ENTER. - The script will now run every 1 minute, 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!
Feedback and suggestions regarding this article are welcome on our Discord server