cURL
is a powerful command-line tool used to transfer data to or from a server. It supports various protocols, including HTTP, HTTPS, FTP, and SFTP, enabling easy downloading directly from the command line.
1. Start by accessing your hosting environment over SSH using a command line tool, if you don’t have one download PuTTY.
2. From here we can start by retrieving a file with cURL, this will display the contents of the file in the terminal window with the following example command.
curl https://www.unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svg
3. Moving on, the command above can be modified with either:
-O
(Uppercase) – Saves the file with the original name similar to a normal save function. The command itself doesn’t need additional information. -o
(Lowercase) – Create a new name for the file acts as a save as function. You will need to add the new filename before the target.If the URL has has an redirects add the -L flag to the command, this ensures that cURL follows redirects which is important for some URLS. A good example of this would be http:// to https:// redirects when http is entered with the -L flag it will redirect correctly.
curl -o -L http://unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svg
Similarly you can use cURL with FTP and SFTP ensure that you add the -u
flag if you have authentication enabled. An example command is shown below using FTP, this can be swapped/interchanged with SFTP depending on your preference.
curl -u root:root*password ftp://ftp.yourftpserver.tld/backup.tar.gz