Is it possible to set the Magento encryption key when using the magento setup:install command for unattended installation?

There does not appear to be a specific option for the encryption key. I tried adding --magento-init-params="crypt[key]=$encryption_key", but no luck.

In theory I could use sed or similar to edit the encryption key immediately after installing, but I would prefer to avoid this approach if possible.

Using Magento 2.2.4 on Ubuntu 18.04.

1 Answer 1


yes it is possible. try:

magento setup:install --key="YOURKEYHERE" ... OTHER ARGS ...

  • 1
    I actually found this and tried it, but I got an error. As I recall it was something along the lines of Encryption key cannot be longer than 32 bytes. Is there a particular way the key has to be formatted? I was just specifying it in hex as it appears in env.php. Aug 28, 2018 at 16:51
  • It worked for me—I just used an ASCII key like the one autogenerated by Magento which was exactly 32 characters. Nov 13, 2018 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.