Upload/download files using the CLI

I just had to download a file from an ownCloud public directory [1] with authentication (a password was set) directly onto a server and came around to use the excellent tool cadaver again.

It is available in most distributions (I only checked Debian, Ubuntu and Arch), so you should be able to just install it using the package manager of your distribution, e.g. like so on Ubuntu:

# as root
apt-get install cadaver

Once that is completed successfully you can connect to a server.

  1. Either by giving it the webdav URL directly as CLI argument like so:
    cadaver https://<owncloud FQDN(/path)?>/remote.php/webdav
  2. Or just starting it, with cadaver and then using the open command in it’s own little REPL

This will then ask you for your username and password and once entered correctly you are connected to the server.

On it’s REPL you can use the help command to see all available commands. And help <command> to learn more about how to use a specific command.

Use get to download a file and put for uploading [2].

But to get back to the public link use case:

You need to instead of the private WebDAV connect to the public WebDAV, which is a little different:
https://<owncloud FQDN(/path)?>/public.php/webdav
When starting the connection this will again ask you for username and password, which might seem a little confusing. But all you have to do is enter the public link token[3] as the username. If the public link is password protected, enter the password as password, otherwise just keep it empty. Et voilà, you are done!

Remember, if it is a big file to download, you might want to start it in a screen session, so it is not a problem if you loose connection to the server and the download keeps running in the background.


[1] If the public link is just a file, it is not available via WebDAV, you will have to use curl directly to download it: curl -u '<token>:<password>' https://<owncloud FQDN(/path)?>/public.php/webdav -o <filename.ext> (or the equivalent wget command)
[2] For public link file drops use Accessing ownCloud Files Using WebDAV :: ownCloud Documentation
[3] A public link usually looks like this: https://<owncloud FQDN(/path)?>(/index.php)?/s/deisL96qgid5tYO. The token is the part at the end of the URL, in this case deisL96qgid5tYO

1 Like