Password protection #2274
Replies: 15 comments 12 replies
-
@Shadow27374 AFAIK, Option 2: |
Beta Was this translation helpful? Give feedback.
-
Thanks already for that, I probably got it. I have now taken the example configuration and only the line for the default password: docker-compose looks like this:
Have I missed anything? |
Beta Was this translation helpful? Give feedback.
-
I have now played around a bit and found that the config is loaded very well. If I disable any feature and restart Glances it is disabled. However, the password protection can not be activated. No matter what I enter as password in the config, the page loads without asking for a password. |
Beta Was this translation helpful? Give feedback.
-
I had your questions aswell. Im running on docker via Unraid so everything wasnt fitting my setup and im kinda novice. Maybe not how one should do it but atleast i got it to work. -Changed to own conf file as you did and stored it on custom location "/mnt/user/appdata/glances", that i confirmed was working as u did. -Created the pwd file and copied to other location as documentation said and i think u did as well. I opted for moving it to custom location (in my case same as conf: /mnt/user/appdata/glances). with file name "yourusername".pwd.
-Then edited GLANCES_OPT to: First i didnt seem to work as it let me in without auth but i think it was cached in the browser i was using during testing. But it worked as i needed to use user/pass when setting up integration to Home Assistant and when i tested in other browser. |
Beta Was this translation helpful? Give feedback.
-
What you describe would be option 1 without changing the config. Anyway, I tried it again now and it works. Since option 1 now works, I let that stay with option 2. |
Beta Was this translation helpful? Give feedback.
-
@Shadow27374 Did I get that right? |
Beta Was this translation helpful? Give feedback.
-
Yes, exactly.
Option 2 actually looked easier but somehow I am too stupid. |
Beta Was this translation helpful? Give feedback.
-
This was confusing me too, thanks for investigating it. Edit: It's actually not working for me, Portainer is giving this error when I try to update the stack (docker-compose.yml): Here is my stack:
Did either of you encounter something like this? |
Beta Was this translation helpful? Give feedback.
-
@RazCrimson
For such configuration, I'm getting information that ``--password` flag is not accessible. Maybe I need to start docker container as nonroot user somehow? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Just tried to set this up, config password has no effect. |
Beta Was this translation helpful? Give feedback.
-
I also cannot get the passwords block in the config file to work which is really unfortunate because it's objectively the more easily reproducible deployment strategy with just being a config file. Hopefully it gets fixed soon but glad to get confirmation here I'm not crazy. |
Beta Was this translation helpful? Give feedback.
-
It sounds like I'm not the only one facing this problem. |
Beta Was this translation helpful? Give feedback.
-
Ahh, any update on this! March 2025 |
Beta Was this translation helpful? Give feedback.
-
I got "option 1" working, but Glances is a bit too picky about all of this... I didn't even try "option 2", because I don't want a plaintext password in with the rest of the config... Sometimes I got no output at all if the arguments were a bit off. For example:
Also, the official docs (for version 4.3.0.7) say that the password file is a (plain) SHA hash, but it's not, it's a PBKDF2 salt and hash (using SHA256). It's good that it's not a plain SHA256 hash, but the docs are a bit misleading. And the password file cannot have a trailing newline, so it's difficult to create the file manually with most text editors (a simple Below are the steps that I took to get this working. My compose.yaml file (note that you cannot use quotes with services:
glances:
container_name: glances
hostname: glances
image: nicolargo/glances:latest-full
restart: unless-stopped
environment:
- TZ=Europe/Helsinki
- GLANCES_OPT=-w --password
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
# Enable the below line after copying the password file out of the container
#- ./glances.pwd:/root/.config/glances/glances.pwd:ro
pid: host
stdin_open: true
tty: true
security_opt:
- apparmor=unconfined
network_mode: host
# Ports for reference only (not needed with network_mode: host)
#ports:
# - 61208:61208
# - 61209:61209 NOTE: With the above compose file, you will get no output in the Docker logs, because Glances is "stuck" asking interactively for a password. You can initially remove First, start the container with Docker Compose. Then, to generate the password file, run these commands (if you're using a different Docker image, change the image tag, or just get the container ID from # Start another instance of Glances inside the container, to generate the password file
docker exec -it "$(docker ps -q --filter ancestor=nicolargo/glances:latest-full)" glances -w --password
# Input your password, choose "Yes" to save it to a file, then Ctrl+C to quit Glances
# Copy the generated file from the container to the host machine
docker cp "$(docker ps -q --filter ancestor=nicolargo/glances:latest-full)":/root/.config/glances/glances.pwd glances.pwd After running the above commands, enable the volume mount for the password file in the compose file: volumes:
- ./glances.pwd:/root/.config/glances/glances.pwd Then recreate the container, and password login should be working. But if Glances quietly (for this too, no logs in Docker) rejects your password, check the volume mount and that the password file doesn't have a trailing newline... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with password protection for Docker.
I do not fully understand the instructions: https://glances.readthedocs.io/en/latest/docker.html#how-to-protect-your-dockerized-server-or-web-server-with-a-login-password
In option 1 you have to create a password file, so far so good, but what is the format of this file? I can't find anything about this.
Option 2 I do not understand at all. It talks about a localhost password. What is that supposed to be? I would like to add a user myself, e.g. admin:pass.
In the Config are only the following:
#localhost=abc
#default=defaultpassword
No matter what I enter it has no effect.
That the # must be gone is already clear...
Beta Was this translation helpful? Give feedback.
All reactions