Use Rclone FTPS
- Rclone is a command-line tool used to manage and transfer files across many storage providers and protocols, including FTP, FTPS, and SFTP.
- This guide explains how to install Rclone on a Linux machine on your local network, configure it to connect to your Ultra.cc service using explicit FTPS on port 21, and optionally automate downloads from your Ultra.cc service to your local machine.
Prerequisites
Before you begin, you will need:
- A Linux machine on your home or local network.
- macOS may also work, but it is not covered directly in this guide.
- Basic command-line knowledge.
- Your Ultra.cc service hostname.
- Example: servername.usbx.me
- Your Ultra.cc service username.
- Your Ultra.cc SSH/FTP password.
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
sudouser, but it is recommended to install rclone asrootuser and later set up rclone under a sudo/sub-user, never set up underroot. - 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
ultrauser.
su ultra- Type
cdto 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
Nthen ENTER to configure a new remote. - Now enter a name: you will need this later when writing our automated script.
- When asked for the storage type, select:
FTP. The number for FTP may change between Rclone versions, so choose the option named FTP rather than relying on a specific number. - Use the following settings when prompted:
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
remotewith 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
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- If you ever get a flock failed command, simply delete the lock file in
~/lockby 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
remotewith the name you selected for your remote. - Make sure to replace
ultrafoldertocopyto match the folder you wish to download. - Also, make sure to edit the
/home/ultra/pathtosavefilesto 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+XthenYand 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
ultrawith 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+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!