Pete Freitag Pete Freitag

Setting Lucee Admin Password with CommandBox

Updated on April 23, 2021
By Pete Freitag
coldfusion

One of the recent changes to Lucee is that no longer allows you to enter an admin password from the web based lucee admin if one had not been set yet. This is a great feature for security, but for local development it makes things a bit more cumbersome.

You'll see what I mean when you hit this error message:

No Password Set Yet!

For security reasons it is no longer possible to set the initial password here directly. You will need to configure a password before you can access the Server Administrator.

  • create a file with the name password.txt containing your new password under the root Lucee Server Directory ( /lucee-server/context/password.txt )
  • click "import file", Lucee will then read and configure your new password, afterwards Lucee will automatically delete that file.

Fixing it CommandBox Style with CFConfig

Assuming you already used commandbox to start the server, just make sure you are in the server's root directory and run these two commands from CommandBox:

install commandbox-cfconfig
cfconfig set adminPassword=Password123!

If you already have cfconfig installed, it doesn't hurt to run install commandbox-cfconfig anyways - it will just make sure you have the latest version installed.

On more recent versions of lucee you will need to restart your lucee server for the password to be picked up.

server restart

Another way to go

Here's a great tip from Brad, the guy who invented CommandBox, cfconfig, and author of the yet to be published book 103 CommandBox Tips on another (possibly better) way to do it:

propertyFile set ~/.box.env cfconfig_adminPassword Password123!
install commandbox-cfconfig
install commandbox-dotenv

With this approach you are creating a file in your home directory called .box.env and setting the variable cfconfig_adminPassword=Password123!. When the commandbox-dotenv command is installed it will intercept your server start and load environment variables from some default locations such as ~/.box.env or a file called .env in the root folder of your server.

The advantage of this second approach using the env file in your home directory is that it will apply to every new server you start.

After you run the above commands, you can just restart lucee, hit the Lucee Admin page, and enter your new password. You might also want to choose a different password besides Password123! that's mine! Just kidding.



commandbox lucee

Setting Lucee Admin Password with CommandBox was first published on September 02, 2020.


Fixinator

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.


Try Fixinator

CFBreak
The weekly newsletter for the CFML Community


Comments

Just FYI, the steps above work. However, you have to restart the server, not just reload the Lucee admin page. (This could be a new thing, I'm not sure, just now getting into CommandBox usage.) At least as of: CommandBox 5.2.1+00295
by Will B. on 01/20/2021 at 4:41:57 AM UTC
Thanks Will - I noticed that too, I wasn't the case when I wrote the article, but it was the next time I tried it. So I will update the article, thanks for the reminder!
by Pete Freitag on 01/20/2021 at 2:54:58 PM UTC
And just a note, if you run several servers, I believe you need to tell it which server it applies to, such as: cfconfig set adminPassword=123password! to=myServerA
by Jonas Eriksson on 11/10/2021 at 4:16:39 PM UTC
I've noticing the same behavior as Jonas as of 5.4.x.
by Tom on 03/02/2022 at 7:26:59 PM UTC
Working with Brad Wood, I discovered my environment is pretty messed up so my previous comment is due to my environment rather than some update made to CFConfig.
by Tom on 03/02/2022 at 10:50:45 PM UTC