Repository navigation
Description
The associated forum post URL from https://forum.rclone.org
none
What is the problem you are having with rclone?
When using rclone to serve the content of a file system through S3, you can run it with a command like this:
rclone serve s3 --auth-key ACCESS_KEY_ID,SECRET_ACCESS_KEY remote:path
Usually it is possible to substitute CLI parameters with environment variables, in this case you could define RCLONE_AUTH_KEY=ACCESS_KEY_ID,SECRET_ACCESS_KEY instead of using the CLI parameter --auth-key. Keeping credentials out of the command line is better for security anyway.
Since v1.70.0 this no longer works. The last version where rclone considered the environment variable RCLONE_AUTH_KEY is v1.69.3.
The documentation states:
If
--auth-keyis not provided then serve s3 will allow anonymous access.
So since v1.70.0 rclone ignores RCLONE_AUTH_KEY and falls back to anonymous access.
What is your rclone version (output from rclone version)
rclone v1.72.1
- os/version: alpine 3.23.0 (64 bit)
- os/kernel: 5.14.0-570.58.1.el9_6.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.25.5
- go/linking: static
- go/tags: none
As I stated before. Every version since and including v1.70.0 is affected.
Which OS you are using and how many bits (e.g. Windows 7, 64 bit)
Linux, x64, container image
Which cloud storage system are you using? (e.g. Google Drive)
none
The command you were trying to run (e.g. rclone copy /tmp remote:tmp)
rclone serve s3 /data
with environment variables set:
RCLONE_ADDR=:8888
RCLONE_AUTH_KEY=[...],[...]
A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)
The debug logs from rclone serve s3 contain these lines:
2025/12/15 15:14:31 DEBUG : Setting auth_key="{user},{pw}" from environment variable RCLONE_AUTH_KEY
2025/12/15 15:14:31 DEBUG : Setting --auth-key "{user}" from environment variable RCLONE_AUTH_KEY="{user},{pw}"
2025/12/15 15:14:31 DEBUG : Setting --auth-key "{pw}" from environment variable RCLONE_AUTH_KEY="{user},{pw}"
... implying, rclone still reads the environment variable, but doesn't apply it.
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Activity
ncw commentedon Dec 15, 2025
Any chance you could git bisect this to pinpoint the problem?
static-moonlight commentedon Dec 16, 2025
Sorry, I'm not much of a code person ;-) I narrowed down the first affected release, best I can do for now.
ncw commentedon Dec 17, 2025
I see what is going on here
$ RCLONE_AUTH_KEY=user,pass rclone-v1.72.0 serve s3 -vv /tmp/srcNotice rclone has split user and pass here
And they are being ignored here
So what is happening is that the new parsing code introduced in in one of these commits is treating
user,passas two pairs oneuserand onepasswhich are being discarded because they don't have a comma in.cf571ad
21e5fa1
b145683
4d9a165
b930c4b
0b7be6f
cebd588
780f404
There is a simple work-around. The arguments to
RCLONE_AUTH_KEYare being treated like a line in a CSV file for escaping purposes, so putting in some quotes will fix itThis also means we can have multiple user/pass pairs which didn't work before
I think that parsing the keys is important so we shouldn't have just been ignoring an error in them. So I propose we change these warnings into fatal errors. That stops any security problems.
Then probably we need to document the setting of the environment variable better.
What do you think?
static-moonlight commentedon Dec 17, 2025
Sounds good. I will also apply the workaround, so that I'm not stuck with an older version.
And yes, the documentation should definitely reflect that.
Thank you for investigating! :)
ncw commentedon Dec 17, 2025
I've made the error be fatal so if you don't have the quotes it should stop rather than serving anonymously
v1.73.0-beta.9364.1d200580d.fix-serve-s3-env-auth on branch fix-serve-s3-env-auth (uploaded in 15-30 mins)
I also updated the docs - what do you think?
Like all rclone flags
--auth-keycan be set via environmentvariables, in this case
RCLONE_AUTH_KEY. Since this flag can berepeated, the input to
RCLONE_AUTH_KEYis CSV encoded. Because theaccessKey,secretKeyhas a comma in, this means it needs to be inquotes.
Or to supply multiple identities:
Setting this variable without quotes will produce an error.
static-moonlight commentedon Dec 17, 2025
Nicely done. That should solve everything. Thank you for the quick response and fix!
ncw commentedon Dec 18, 2025
Thanks for testing.
I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.73 - I may put this in the next point release also.
serve s3: make errors in --s3-auth-key fatal - fixes rclone#9044
serve s3: make errors in --s3-auth-key fatal - fixes rclone#9044
serve s3: make errors in --s3-auth-key fatal - fixes rclone#9044
Sync from rclone/rclone (#1)
Upgrade rclone to v1.73.0, fix auth_key quoting
Upgrade rclone to v1.73.0, fix auth_key quoting
serve s3: make errors in --s3-auth-key fatal - fixes rclone#9044