# Dashboard and Metrics basicAuth using usersFile

**URL:** <https://community.traefik.io/t/dashboard-and-metrics-basicauth-using-usersfile/7291>\
**Category:** Traefik v2\
**Tags:** dashboard-api, file, middleware, docker, metrics\
**Created:** [August 13, 2020, 10:10pm UTC](https://community.traefik.io/t/dashboard-and-metrics-basicauth-using-usersfile/7291 "2020-08-13T22:10:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tam481](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tam481/32/2310_2.png) [@tam481](https://community.traefik.io/u/tam481)\
**Post date:** [August 13, 2020, 10:10pm UTC](https://community.traefik.io/t/dashboard-and-metrics-basicauth-using-usersfile/7291/1 "2020-08-13T22:10:05Z")

</div>

Hi,  
I'm having a problem getting dashboard and metrics authentication to work when using an external usersFile created using htpasswd

If I manually set the username and password in the traefik.yml file authentication works fine. However, when I swap that for usersFile I keep getting error 401 unauthorised in prometheus and prompt to enter username and password for the dashboard page.

I am generating the password using the following command:  
`echo $(htpasswd -nB $input) | sed -e s/\\$/\\$\\$/g > $DIR/.passwd`

Here is the relevant part in the config.yml file for Traefik

```auto
  middlewares:
    auth-dashboard:
      basicAuth:
        usersFile: "/etc/traefik/.passwd"
# users:
# - "admin:$apr1$skWr6iM7$ybokdopHX/dZvkAlqgmHk0"

```

I inspected the container and the password file is visible, permissions are correct. I tested this and got error 404 when the file name is changed. If I uncomment users and the subsequent line I can access the dashboard page. The same goes for prometheus but if I use a usersFile it doesn't work.

How can I fix this?
