3

I configured in /etc/mongod.conf to enforce keyfile access control, in security option enabled, keyFile is /root/dbtest.key (the absolute path of keyfile). I already gave the ownership to mongodb user by chown, and granted 400 permission on that dbtest.key file.

But mongod keeps failing to start, after checking log, the error is Error reading file /root/dbtest.key: Permission denied. After checking the ownership and permissions on dbtest.key

Which means I already granted correctly. So I don't know at which step I did wrong

1
  • What O/S are you using and how are you starting the MongoDB server? What are the permissions for the /root directory where the keyfile currrently lives? The mongod process will need to to have read permission for the directory as well as the keyfile. I suspect you should use a path other than /root, since this is normally the root user's home directory with access restricted to the root user.
    – Stennie
    Aug 3, 2019 at 7:50

1 Answer 1

0

@Stennie Comment was right! I have just moved my keyfile from my home user /home/user/keyfile to a directory where mongodb is owner: /var/lib/mongodb/keyfile. Also remember keyfile must have 400 permissions and be owner and group of mongodb: chmod 400 keyfile chwon mongodb:mongodb keyfile

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.