Can credentials for rclone serve webdav be defined in env vars?

What is the problem you are having with rclone?

I would like to know if I can serve a remote over webdav and define the user/pass via environment variables instead of command line flags or htpasswd files.

I know config can be set entirely via environment variables (Documentation) and I'm hoping these flags can be as well.

rclone works and authentication works well with command line flags and htpasswd.

Run the command 'rclone version' and share the full output of the command.

rclone v1.65.2

  • os/version: debian 12.4 (64 bit)
  • os/kernel: 6.6.32-production+truenas (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.19.8
  • go/linking: dynamic
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone serve webdav myonedrive:

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

Config is empty as it is set by environment variables.

A log from the command that you were trying to run with the -vv flag

N/A. Command runs fine.

It should. Have you tried? Does it work?

BTW - you are using old rclone version. Uninstall it and install the latest directly from rclone website.

Thanks for the quick response! I've installed the latest version. I tried guessing the environment variables as I could not find them in the documentation. Below are the vars I tried. None appear to be picked up by rclone, and the webdav server is still accessible without authentication.

RCLONE_SERVE_USER=XXX
RCLONE_SERVE_PASS=XXX

RCLONE_SERVE_WEBDAV_USER=XXX
RCLONE_SERVE_WEBDAV_PASS=XXX

RCLONE_CONFIG_USER=XXX
RCLONE_CONFIG_PASS=XXX

RCLONE_CONFIG_SERVE_USER=XXX
RCLONE_CONFIG_SERVE_PASS=XXX

RCLONE_CONFIG_SERVE_WEBDAV_USER=XXX
RCLONE_CONFIG_SERVE_WEBDAV_PASS=XXX

Logs below:

Summary

2024/09/23 13:28:54 DEBUG : rclone: Version "v1.68.0" starting with parameters ["rclone" "serve" "webdav" "myonedrive:" "-vv"]
2024/09/23 13:28:54 DEBUG : Creating backend with remote "myonedrive:"
2024/09/23 13:28:54 DEBUG : Using config file from "/home/XXX/.config/rclone/rclone.conf"
2024/09/23 13:28:54 DEBUG : Setting type="onedrive" for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_TYPE
2024/09/23 13:28:54 DEBUG : Setting token=XXX for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_TOKEN
2024/09/23 13:28:54 DEBUG : Setting drive_id=XXX for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_DRIVE_ID
2024/09/23 13:28:54 DEBUG : Setting drive_type="personal" for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_DRIVE_TYPE
2024/09/23 13:28:54 DEBUG : myonedrive: detected overridden config - adding "{IqmJv}" suffix to name
2024/09/23 13:28:54 DEBUG : Setting drive_id=XXX for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_DRIVE_ID
2024/09/23 13:28:54 DEBUG : Setting drive_type="personal" for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_DRIVE_TYPE
2024/09/23 13:28:54 DEBUG : Setting token=XXX for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_TOKEN
2024/09/23 13:28:54 DEBUG : Setting token=XXX for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_TOKEN
2024/09/23 13:28:54 DEBUG : myonedrive{IqmJv}: Loaded invalid token from config file - ignoring
2024/09/23 13:28:55 DEBUG : Setting token="XXX" for "myonedrive" from environment variable RCLONE_CONFIG_MYONEDRIVE_TOKEN
2024/09/23 13:28:55 DEBUG : Saving config "token" in section "myonedrive" of the config file
2024/09/23 13:28:55 DEBUG : myonedrive{IqmJv}: Saved new token in config file
2024/09/23 13:28:56 DEBUG : fs cache: renaming cache item "myonedrive:" to be canonical "myonedrive{IqmJv}:"
2024/09/23 13:28:57 DEBUG : OneDrive root '': Next delta token is: XXX
2024/09/23 13:28:57 NOTICE: OneDrive root '': --vfs-cache-mode writes or full is recommended for this remote as it can't stream
2024/09/23 13:28:57 NOTICE: OneDrive root '': WebDav Server started on [http://127.0.0.1:8080/]

Solved. The correct environment variables are:

RCLONE_USER=XXX
RCLONE_PASS=XXX

Thanks for your time!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.