Nacos does not enable account and password login by default, but you can enable account and password login by modifying the configuration to enhance security. The following are the steps to enable account and password login in Nacos:
-
Open the Nacos configuration file
nacos/conf/application.properties
. -
Add the following configuration to the file to set the username and password:
### Security ###
nacos.core.auth.enabled=true
nacos.core.auth.username=your_username
nacos.core.auth.password=your_password
Pay attention to
the reason why the authentication switch is not enabled in the new version of the configuration file. Specifically, you can modify the following configuration items and configure them as follows
nacos.core.auth.enabled=true
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:example}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_KEY:example}
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey01234567890123456789012345345678999987654901234567890123456789}
-
Replace
your_username
with the username you want to set, andyour_password
replace with the password you want to set. -
Save and close the configuration file.
-
Restart the Nacos server to make the configuration take effect.
-
When accessing the Nacos console, you will be asked to enter a user name and password for login verification.
Please ensure the security of your username and password, and avoid using weak passwords to protect your Nacos services.
In addition, Nacos also provides more security settings and permission control options, such as role-based permission control. You can find more detailed information in the official documentation: https://nacos.io/zh-cn/docs/security.html
To modify the Nacos account password through the configuration file, you can follow the steps below:
-
Open the Nacos configuration file
nacos/conf/application.properties
. -
Add the following configuration and modify the username and password:
### Security ###
nacos.core.auth.enabled=true
nacos.core.auth.username=new_username
nacos.core.auth.password=new_password
-
Replace
new_username
with the new username you want to set andnew_password
replace with the new password you want to set. -
Save and close the configuration file.
-
Restart the Nacos server to make the configuration take effect.
Please note that when using the configuration file to modify the account password, you need to keep the configuration file carefully to avoid leaking sensitive information. At the same time, make sure the new username and password are safe enough to protect your Nacos service.