Jul 24, 2019 by Georgi Nikolov | 11582 views
Nextcloud is a great tool for self-hosting your data in the vein of Dropbox. It facilitates exchange of information and files in a team, with the extra benefit of providing a robust monitoring and protection capabilities. There are Nextcloud clients available for Windows, Linux and MacOS, which are easy to install and use. With one click you can upload your files to your personal cloud and share them. But sometimes the need arises to upload files from machines that don't use a Graphical user Interface (for example Ubuntu Server distribution). Luckily there exists a way to still be able to upload your files to Nextcloud using the command line and Curl.
I encountered this problem while preparing a scenario for one of our classes, where we simulated a virtual network of multiple machines. We had a Windows machine running in a subnet and a File Server and a Honeypot running in a separate subnet. When a user of the network needed to transfer files from and to the File Server, he would use FileZilla. But what about if you want to have a more in-depth look at the log files stored on the File Server or Honeypot? Should you pass through the Windows Machine and use FileZilla to copy the files from those servers to the Win computer? And if you want to upload them to Nextcloud so you can share them with your team? This might seem like a very niche problem, but it is one I encountered recently and spent quite some time finding a solution, where I could upload the log files directly from the File Server and Honeypot to Nextcloud, without using another computer as a middle-man.
Luckily I discovered a short bash script written by someone online, which I will share here with you.
curlis not present on your server you can easily install it using the following command:
$ sudo apt-get update $ sudo apt-get install curl
You can verify the version of
curl with the command
You can download the script by using curl:
$ curl -O 'https://gist.githubusercontent.com/tavinus/93bdbc051728748787dc22a58dfe58d8/raw/cloudsend.sh' && chmod +x cloudsend.sh
chmod +x helps us use the *.sh script as an executable
./cloudsend.sh instead of having to everytime type
The script is used in the following fashion:
$ ./cloudsend './myfile' 'https://cloud.mydomain.com/s/file-drop-link'
Now we can easily upload files directly to our File Drop Nextcloud link in 3 easy steps. Enjoy!