Skip to content

Add the ability to reset the admin password if the user forgot it #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
liyaka opened this issue Jan 19, 2017 · 48 comments
Closed

Add the ability to reset the admin password if the user forgot it #512

liyaka opened this issue Jan 19, 2017 · 48 comments
Labels
area/authentication kind/enhancement Applied to Feature Requests

Comments

@liyaka
Copy link

liyaka commented Jan 19, 2017

No description provided.

@deviantony
Copy link
Member

deviantony commented Jan 20, 2017

@liyaka You can only change the admin password via the UI. What do you mean by option?

@deviantony deviantony added kind/enhancement Applied to Feature Requests status/need-info and removed kind/enhancement Applied to Feature Requests labels Jan 20, 2017
@luckydonald
Copy link

luckydonald commented Jan 21, 2017

Delete the data folder / volume, probably.

@liyaka
Copy link
Author

liyaka commented Jan 22, 2017

@deviantony if the user forgot the password, there is no option (in UI at least ) to reset the password

@deviantony
Copy link
Member

@liyaka no, there is no way to reset the admin password if you forgot it at the moment. We'll track this evolution here.

@deviantony deviantony changed the title Is there an option to reset admin password? Add the ability to reset the admin password if the user forgot it Jan 22, 2017
@hammady
Copy link

hammady commented Nov 8, 2017

Maybe the --admin-password flag could be overloaded. Currently, it skips admin user creation if it exists. What I suggest is to reset the admin password if a user was found. Security wise, a user with access to recreate the container should be given access to reset the password as well.
This is very convenient instead of going to all manager nodes, deleting volumes then recreating the container (or service)

@deviantony
Copy link
Member

I don't think this is the way to go as the admin user can also change his password from within the UI. Meaning that these changes would be overwritten after a restart of the container. That would probably cause troubles.

@hammady
Copy link

hammady commented Nov 9, 2017 via email

@luckydonald
Copy link

How about --reset-password resets you to the choose password for admin gui?

@colegatron
Copy link

colegatron commented Feb 15, 2018

How about --force-create-user in order to be able to recreate the admin user to let reset the password if administrator exists?

In my case I try to automate as much as possible everything, meaning having to change a password through an UI is usually not an option.

Also the deletion of the data volume/folder is either an option because you'll end up loosing your config, don't you?

@darkpixel
Copy link

Yeah, deleting the volume causes every stack you have deployed to show up as 'external' and you can't do anything with them. I really don't want to destroy all the stacks in my cluster only to paste them back into portainer to spin them up again.

@luckydonald
Copy link

luckydonald commented Apr 4, 2018

The web gui is able to set it. So the node package should just expose a command to run to do the same, with shell access instead of being logged on.

docker-compose exec portainer  npm run portainer-reset-password

I'm not into node that much, but I've seen this be done somehow like this.

@Codelica
Copy link

An older issue here, but we have the need for this as well. Basically wanting to always control the admin password via startup flag(s). Something like an extra --force-* flag seems safe enough, and certainly a better option the loosing config and stack control.

@sisiliao
Copy link

sisiliao commented Oct 31, 2018

Is there a workaround on this ?? something like reseting password if someone forget, not through the gui tho??

@pcgeek86
Copy link

I forgot my password and would like an option to reset it. I suppose I can start a new Portainer container, but that seems counter-intuitive to me. Thanks for the great work you guys are doing on this project! I can't believe I didn't start using this earlier.

@ghost
Copy link

ghost commented Jan 12, 2019

My temporary solution with boltbrowser
Stop portainer, edit portainer.db with boltbrowser and start portainer.

Works great - but a flag could be better.

@Duvel
Copy link
Contributor

Duvel commented Jan 14, 2019

@gisselmann that worked for me as well after the upgrade to 1.20.0 broke my LDAP logon.

For others: remove all users in the bolt db and portainer will ask again for a password.

@kongh
Copy link

kongh commented Aug 19, 2019

Today some one (a attack application)is attacking my portainer , because he gueess my password and got the jwt token and not expired, after I change my simple password , but he changed it quickly.

How to improve Safety ?This is a problem.

Add human validation for the change password api is necessary.

@joseluisq
Copy link

@gisselmann @Duvel both options didn't work for me. I always got: "access denied to resource".
We are using LDAP.
Unfortunately the only solutions was to deploy a new docker stack without LDAP and re-entry our stack configurations.

@Rogiel
Copy link

Rogiel commented Aug 19, 2019

Today some one (a attack application)is attacking my portainer , because he gueess my password and got the jwt token and not expired, after I change my simple password , but he changed it quickly.

How to improve Safety ?This is a problem.

Add human validation for the change password api is necessary.

I have also noticed an attack starting today. The attacker is probably not gaining access to your account. What seems to be happening is that Portainer is blocking authentication after 12 failed attempts. The bot is still trying to guess the password after that and authentication remains locked and since authentication is disabled you can't access Portainer.

I would recommend you to block port 9000 and use a frontend server with nginx (or apache if you prefer it). Better yet, block to everything and everyone but your IP address.

2019/08/19 17:15:58 Instance already has defined endpoints. Skipping the endpoint defined via CLI.
2019/08/19 17:15:58 Starting Portainer 1.21.0 on :9000
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Access denied (err=Access denied to resource) (code=403)

@kongh
Copy link

kongh commented Aug 19, 2019

yeah, i cannot agree more. I had changed the port of portainer and the password , because of my weak password. this is an attack event, disabled the whole authentication is not the best idea, human validation may be can resovle it.

this attack effected our applicatiins deploy in japan ,korea, china servers

@liuzhaowei55
Copy link

Today some one (a attack application)is attacking my portainer , because he gueess my password and got the jwt token and not expired, after I change my simple password , but he changed it quickly.
How to improve Safety ?This is a problem.
Add human validation for the change password api is necessary.

I have also noticed an attack starting today. The attacker is probably not gaining access to your account. What seems to be happening is that Portainer is blocking authentication after 12 failed attempts. The bot is still trying to guess the password after that and authentication remains locked and since authentication is disabled you can't access Portainer.

I would recommend you to block port 9000 and use a frontend server with nginx (or apache if you prefer it). Better yet, block to everything and everyone but your IP address.

2019/08/19 17:15:58 Instance already has defined endpoints. Skipping the endpoint defined via CLI.
2019/08/19 17:15:58 Starting Portainer 1.21.0 on :9000
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:58 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:15:59 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Invalid credentials (err=Unauthorized) (code=422)
2019/08/19 17:16:00 http error: Access denied (err=Access denied to resource) (code=403)

The same question.

@soydepr
Copy link

soydepr commented Feb 20, 2020

My temporary solution with boltbrowser
Stop portainer, edit portainer.db with boltbrowser and start portainer.

Works great - but a flag could be better.

where is file located

@tasz
Copy link

tasz commented Mar 9, 2020

where is file located
/var/lib/docker/volumes/portainer_data/_data

@tasz
Copy link

tasz commented Mar 9, 2020

if you add this hash using boltbrowser it will ask to reset password.
$2b$10$5Zv9.JQx3QJ0fVgt8TBnnuSxtNq9lKpTRtciEQknB2U7woYABBauS

@mangei
Copy link

mangei commented Mar 20, 2020

@tasz what is this hash? I couldn't find anything. can you please link to the source/documentation?

@mnasafi
Copy link

mnasafi commented Apr 30, 2020

For Open Media Vault (OMV 5+) users, the procedure to reset Portainer password is:

  1. Remove "Portainer" in OMV-Extras --> Docker Tab --> Portainer --> Remove
  2. SSH login as root / sudo user into your OMV server and execute the command:
    docker volume rm portainer_data
  3. Reinstall Portainer under the Docker Tab in OMV-Extras

You might need to clear your browser cache or open a new private window before accessing the portainer web interface.

Note: portainer interface runs on Port 9000. e.g. http://Server-IP-address:9000

@rjgonza
Copy link

rjgonza commented Apr 30, 2020

For Open Media Vault (OMV 5+) users, the procedure to reset Portainer password is:

1. Remove "Portainer" in OMV-Extras --> Docker Tab --> Portainer

2. Login into SSH terminal as root user and execute the command: ' docker volume rm portainer_data '

3. Reinstall Portainer under the Docker Tab in OMV-Extras

You might need to clear your browser cache or open a new private window before accessing the portainer web interface.

Note: portainer interface runs on Port 9000. e.g. http://Server-IP-address:9000

Won't this also wipe out your data?

@mnasafi
Copy link

mnasafi commented May 16, 2020

For Open Media Vault (OMV 5+) users, the procedure to reset Portainer password is:

1. Remove "Portainer" in OMV-Extras --> Docker Tab --> Portainer

2. Login into SSH terminal as root user and execute the command: ' docker volume rm portainer_data '

3. Reinstall Portainer under the Docker Tab in OMV-Extras

You might need to clear your browser cache or open a new private window before accessing the portainer web interface.
Note: portainer interface runs on Port 9000. e.g. http://Server-IP-address:9000

Won't this also wipe out your data?

No, the container data is left intact. Upon reinstalling the portainer, the previous data should be still there. I am about to redo the above procedure again since I forgot my portainer login password again.

If you have critical data, I would strongly recommend backing up your data before in-case it gets lost or corrupted before attempting my solution.

Update: It worked a second time for me without the container data loss. However, I still strongly recommend backing up critical data before attempting. What works for my environment might not work for you.

@hertzg
Copy link

hertzg commented May 24, 2020

Removing the portainer_data volume will wipe your portainer configs (certificates, users and configurations).

boltbrowser would be the better way to reset just the password.

@soydepr
Copy link

soydepr commented May 24, 2020

Why adding this feature seems to complicated as a solution seems common sense, would not expect this solution to be dragging so long

The boltbrowser worked perfectly for me

@mnasafi
Copy link

mnasafi commented May 29, 2020

Removing the portainer_data volume will wipe your portainer configs (certificates, users and configurations).

boltbrowser would be the better way to reset just the password.

Can you please list a step-by-step tutorial for resetting Portainer credentials using BoltBrowser. I googled for instructions but wasn't able to find any. Provide as many details as possible.

@rjgonza
Copy link

rjgonza commented May 29, 2020

Removing the portainer_data volume will wipe your portainer configs (certificates, users and configurations).
boltbrowser would be the better way to reset just the password.

Can you please list a step-by-step tutorial for resetting Portainer credentials using BoltBrowser. I googled for instructions but wasn't able to find any. Provide as many details as possible.

I actually did a blog post on this: https://rjgonza.netlify.app/posts/forgot_portainer_password/

@ncresswell
Copy link
Member

ncresswell commented May 29, 2020 via email

@eznix86
Copy link

eznix86 commented May 30, 2020

The boltbrowser does the trick:
Useful commands

apt install unzip

curl -sSL https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linux64.zip -o bolt.zip

unzip bolt.zip

docker volume ls

docker volume ls portainer_data

docker  docker run --rm httpd:2.4-alpine htpasswd -nbB admin 'temporarypassworduntilyoureset'

./boltbrowser.linux64 /path/to/portainer.db
# Go to users and copy paste the password generated from httpd

Thanks @rjgonza

@NightyLive
Copy link

A lot of thanks to @rjgonza and @theArtechnology, his comment is very helpful but there is some little mistakes, also I searched a lot to find out where is the portainer.db before I figured out the container was running and that was the cause to not finding it.

So I rewrited some parts to made an easier procedure for noobs like me :

Password to use: changeme
Password hash to insert in portainer.db: $2y$05$B2tx1L.985tT6ciL1h8uieQq8hJoDHrsK6G2vK/tN3Eg6oTpa4poG
Or generate one of your choice: docker run --rm httpd:2.4-alpine htpasswd -nbB admin changeme

The main part to reset the password (tdnf is PhotonOS package manager, replace by yours (apt etc.):

tdnf install curl unzip
curl -sSL https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linux64.zip -o bolt.zip
unzip bolt.zip
docker container stop portainer
./boltbrowser.linux64 /var/lib/docker/volumes/portainer_data/_data/portainer.db 
# Go to users edit admin and replace the current password hash with the new one
docker container start portainer

@deviantony
Copy link
Member

We also released this helper tool recently to help you reset your password: https://github.com/portainer/helper-reset-password

@bitshiftnetau
Copy link

bitshiftnetau commented Mar 28, 2021

The boltbrowser does the trick:
Useful commands

apt install unzip

curl -sSL https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linux64.zip -o bolt.zip

unzip bolt.zip

docker volume ls

docker volume ls portainer_data

docker  docker run --rm httpd:2.4-alpine htpasswd -nbB admin 'temporarypassworduntilyoureset'

./boltbrowser.linux64 /path/to/portainer.db
# Go to users and copy paste the password generated from httpd

Thanks @rjgonza

This doesn't work. Couldn't pull from http repo, citing some need to login?

Ended up using this to generate the hash, then used these instructions to insert using boltbrowser.

It doesn't work, I cannot login to portainer at this time.

Also it seems that this doesn't work on compiled versions of portainer AND compiled versions don't give an option to set the password.

When is this issue going to be resolved? It shouldn't be this difficult to reset or set a password.

@rjgonza
Copy link

rjgonza commented Mar 28, 2021

I haven't actually checked to see what kind of lift it is, but I won't assume it's simple. There are many considerations when allowing passwords to be overwritten/reset. In any case my example was a specific version of bolt and portainer. Which are you using?

@bitshiftnetau
Copy link

I haven't actually checked to see what kind of lift it is, but I won't assume it's simple. There are many considerations when allowing passwords to be overwritten/reset. In any case my example was a specific version of bolt and portainer. Which are you using?

That is true, I guess I'm just frustrated after a day of trying all things to get it working.

Thanks for responding, turned out to be a system issue. I'm using the Arch Linux package found here I've blown away the /var/lib/portainer folder and re-installed the package. Password set dashboard appeared.

@rjgonza
Copy link

rjgonza commented Mar 28, 2021

I hear ya, that can be pretty annoying. Glad you got it working though 👍

@deviantony deviantony added this to the community-picks milestone Mar 28, 2021
@deviantony deviantony removed this from the community-picks milestone Apr 16, 2021
@deviantony
Copy link
Member

Closing this issue as we're not gonna bring the ability to reset the admin password from within Portainer.

We recommend you to use external authentication or the helper tool we released to help you reset your password via: https://github.com/portainer/helper-reset-password

chiptus pushed a commit that referenced this issue Aug 13, 2021
… and namespace EE-3 (#513)

* metrics api resources calls to get nodes in cluster and pods in namespace

* refactored cpu and memory reservation component to be explicit

* resourceReservation support for memory/cpu usage stats

* removed duplicated description

* feat(kubernetes/resource-usage): k8s resource usage displayed on node view EE-1114 (#511)

* feat(kubernetes/resource-usage): k8s resource usage displayed on node view EE-1114

* review updates

* server metrics variable declaration moved above

Co-authored-by: zees-dev <dev.786zshan@gmail.com>

* feat(kubernetes/resource-usage): k8s resource usage displayed on cluster view EE-1113 (#508)

* authentication helper method to check user role

* resource usage displayed on cluster view

* explicity error notification alert

* removed redundant jsdoc param

* loading resource usage as part of reservations

* feat(kubernetes/resource-usage): k8s resource usage displayed on namespace view EE-1115 (#512)

* refactor cpu/memory used to resourceReservation variables

* resource usage displayed on k8s namespace view

* loading resource usage as part of reservations

* fixed viewready bug

* refactor code to set initial state and remove redundant loading var

* reverting to k8s authorizations for rbac

* utilising view bound endpoint object instead of depracated EndpointProvider

* feat(kubernetes/resource-usage): k8s ClusterRole updates to support metric server api queries EE-1123 (#520)

* updated k8s clusterroles to support metrics api server queries

* updated k8s clusterroles to remove redundant metrics server permissions

* refactor flatmap

* addressed merge conflict issues

Co-authored-by: fhanportainer <79428273+fhanportainer@users.noreply.github.com>
@macagua
Copy link

macagua commented Aug 21, 2021

@luckydonald I deleted the data volume and it's work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/authentication kind/enhancement Applied to Feature Requests
Projects
None yet
Development

No branches or pull requests