从命令行修改odoo 的 Master密码

admin 2021-5-27 259663


If you don't have access to the graphical interface, you will need to change your Odoo Master Password from the command line.

The process involves logging into your Odoo server, creating a hashed (i.e. hard to read) version of the new password, and changing the password value in the Odoo configuration file.

Once you're in the command line of your Odoo server, use the following commands to change your Odoo master password.


Change the current Linux user to odoo:

sudo su odoo


Activate the Odoo virtual environment to have access to the same modules as your Odoo instance:

source /opt/odoo/odoo13-venv/bin/activate


Enter the Python shell:

python3


Import the needed module:

from passlib.context import CryptContext


Now, let's transform and encrypt your new master password using the PBKDF2 SHA512 scheme. The command below will do it, and then display the result:

print(CryptContext(schemes=['pbkdf2_sha512']).encrypt('new_master_password'))

Note: change new_master_password to an actual password that you chose as your new master password. The value must stay wrapped in single quotation marks.

 

When you hit Enter, there will appear long string of text, like this:

$pbkdf2-sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Dr/bx.2b7hg

Copy it or write it down for later use.

 

When you're ready, leave the Python shell:

exit()

 

Exit the odoo Linux user:

exit

 

Open your Odoo configuration file:

sudo nano /etc/odoo.conf

 

Find the line that starts with admin_passwd. It will look something like this:

admin_passwd = $pbkdf2-sha512$10001$0dr7v7eWUmptrfW.9z6HkA$w9j9AMVmKAP17OosCqDxDv2hjsvzlLpF8Rra8I7p/b5746rghZ8WrgEjDpvXG5hLz1UeNLzgFa81Dr/bx.2b7hg

 

As you can see, admin_passwd is a variable, and everything that goes after the '=' sign is a value. The current value represents the hashed version of the old password.

You need to change it to the hashed version of the new password (you created it a few steps above).

Delete the old value and enter the new one.

When you're done, save the file and exit it by pressing Ctrl+X, followed by Y and then Enter.

 

Finally, restart the Odoo service:

sudo service odoo13 restart

 

Congratulations, you have successfully changed your Odoo Master Password from the command line.

 


最新回复 (0)
返回