Authorization error with rc --rc-htpasswd via remote control (Win10)

What is the problem you are having with rclone?

Authorization error with --rc-htpasswd via remote control.
If you use --rc-user and --rc-pass, everything works fine.
At the same time, running the gui using rcd --rc-htpasswd passes without errors

What is your rclone version (output from rclone version)

rclone: Version "v1.55.1"

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Windows 10, 64 bit

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

rclone -vv rc --rc-htpasswd=\rclone\webgui\.htpasswd options/set --json "{\"vfs\": {\"CacheMode\": 3, \"ChunkSize\": 67108864, \"ChunkSizeLimit\": -1, \"DirCacheTime\": 5000000000, \"DirPerms\": 511, \"FilePerms\": 511, \"NoModTime\": true}, \"log\": {\"File\": \"\\rclone\\.rclone\\logs\\rclone.log\"}}"

A log from the command with the -vv flag

2021/05/27 15:24:43 DEBUG : Using RCLONE_CONFIG_PASS password.
2021/05/27 15:24:43 DEBUG : Using config file from "i:\\Rclone\\rclone.conf"
2021/05/27 15:24:43 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone" "-vv" "rcd" "--rc-web-gui-no-open-browser" "--rc-htpasswd=\\rclone\\webgui\\.htpasswd" "--rc-serve" "--rc-files=\\rclone\\webgui\\current\\build" "--buffer-size=1G" "--cache-dir=.rclone"]
2021/05/27 15:24:43 NOTICE: Serving files from "\\rclone\\webgui\\current\\build"
2021/05/27 15:24:43 INFO  : Using "\\rclone\\webgui\\.htpasswd" as htpasswd storage
2021/05/27 15:24:43 NOTICE: Serving remote control on http://localhost:5572/
2021/05/27 15:24:43 NOTICE: Web GUI is not automatically opening browser. Navigate to http://localhost:5572/ to use.
2021/05/27 15:24:43 DEBUG : Using RCLONE_CONFIG_PASS password.
2021/05/27 15:24:43 DEBUG : Using config file from "i:\\Rclone\\rclone.conf"
2021/05/27 15:24:43 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone" "-vv" "rc" "--rc-htpasswd=\\rclone\\webgui\\.htpasswd" "options/set" "--json" "{\"vfs\": {\"CacheMode\": 3, \"ChunkSize\": 67108864, \"ChunkSizeLimit\": -1, \"DirCacheTime\": 5000000000, \"DirPerms\": 511, \"FilePerms\": 511, \"NoModTime\": true}, \"log\": {\"File\": \"\\\\rclone\\\\.rclone\\\\logs\\\\rclone.log\"}}"]
2021/05/27 15:24:43 DEBUG : rc: "core/stats": with parameters map[]
2021/05/27 15:24:43 DEBUG : rc: "core/stats": reply map[bytes:0 checks:0 deletedDirs:0 deletes:0 elapsedTime:0.2981816 errors:0 eta:<nil> fatalError:false renames:0 retryError:false speed:0 totalBytes:0 totalChecks:0 totalTransfers:0 transferTime:0 transfers:0]: <nil>
2021/05/27 15:24:43 DEBUG : 4 go routines active
2021/05/27 15:24:43 Failed to rc: Failed to read rc response: 401 Unauthorized: Unauthorized

You have to clear your browser cache/cookies.

It is not entirely clear what does clearing the browser cache have to do with it?
The rclone GUI works fine, both when using rcd --rc-htpasswd, and when running with --rc-user and --rc-pass. The problem is running remote control rc --rc-htpasswd when working with an already running rclone daemon, but if I use authorization with rc --rc-user --rc-pass, then everything works fine.
Ok I cleared the cookies and browser cache, it didn't help.

This means you have an old cookie in your browser cache.

I installed a clean Window10 x64 on virtualbox, run the same sequence of commands and get the same error, I understand that the cache and cookies should not have affected it, since the system is initially clean?
Maybe I incorrectly explained the sequence of my actions:
Created a bat file
Wrote the commands in it:

1. set RCLONE_CONFIG_PASS=password from the config
2. start /b rclone rcd --rc-web-gui-no-open-browser --rc-htpasswd=\rclone\webgui\.htpasswd --rc-serve  --rc-files=\rclone\webgui\current\build
3. start /b rclone rc --rc-htpasswd=\rclone\webgui\.htpasswd mount/mount fs=test: mountPoint=x:

Here is command 3 and gives an authorization error using --rc-htpasswd and the rc command does not work, but if in command 3, replace --rc-htpasswd=\rclone\webgui.htpasswd on --rc-user=username --rc-pass=user password (this data is the same as in .htpasswd) then everything works fine.
Where is my mistake? I just don't want to keep my username and password publicly available in a bat file. Maybe there is an option to use the RCLONE_HTPASSWD environment variable?

How are you generating the htpasswd information?

rclone touch \rclone\webgui\.htpasswd
htpasswd -B \rclone\webgui\.htpasswd *username*

In the password request, I enter my password - * user password*

For command 3 you need to supply a username and password from the htpassword file as it is connecting to the rclone rcd. So using those credentials so using --rc-user/--rc-pass is what you need to do.

1 Like

I understand correctly, I can't run rcd --rc-htpasswd=\rclone\webgui.htpasswd first and then use the same --rc-htpasswd=\rclone\webgui.htpasswd with rc, but only via --rc-user`/ ' --rc-pass?

Is there a way of using rclone rcd without putting passwords on the command line? I don't want the password appearing in the process list

hello and welcome to the forum,

one way is to use environment variables.
i have a python script that creates environment variables and starts a new process with those environment variables to run rclone.

That doesn't solve the issue if rclone can't read the username and password directly from the environment variables.

at this point, best to start a new post as your issue is not the same as the OP

as far as i know, any program can accept environment variables.

on windows, batch file
rclone ls %source%

for example, using python,

RcloneEnv["RCLONE_CONFIG_PASS"]='thesecretpassword'
x=subprocess.run('rclone listremotes', env=RcloneEnv)

When you run it like that, Python will get the password from the environment variable and then pass the password raw as an argument to rclone (as an element of argv). So the password will still be visible in the process list.

not an expert but the password is not passed as part of argv, as it is an environment variable.
i just checked again.
using task manager, the password is not visible on the command line.

sure, process explorer from sysinternals is able to display environment variables of a running app.

Oh, you are on Windows. I am on Debain, so it is different

that's another reason why i suggested that you start a new topic.
so we do not have to guess about your setup.
give your new topic a good title, we have many linux experts.

1 Like

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