H__D  

一、MongoDB安装

  参考:【MongoDB】MongoDB 安装 - H__D - 博客园 (cnblogs.com)

二、开启auth认证

1、事由

  由于自己服务器上的mongodb未开启认证,导致黑客盯上天,我的MongoDB数据被黑客删库了,还勒索要支付比特币赎回。。。 

  现象:数据库被删,发现多了个库 README_TO_RECOVER_YOUR_DATA, 打开里面居然有要我支付0.01比特币的信息,才意识到数据库被入侵了,具体信息如下

  All your data is backed up. You must pay 0.0067 BTC to xxxxxx In 48 hours, your data will be publicly disclosed and deleted. (more information: go to https://xxxxx)After paying send mail to us: xxxx@onionmail.org and we will provide a link for you to download your data. Your DBCODE is: xxxx

  

2、启动时开启auth认证

  参考:基于角色的访问控制 - MongoDB 手册 v7.0

  启动命令:mongod --bind_ip_all --dbpath /data/soft/mongodb-linux-x86_64-rhel70-7.0.12/mongo --logpath /data/soft/mongodb-linux-x86_64-rhel70-7.0.12/mongodb/mongod.log --port 27017 --auth --fork

3、使用MongoDB shell进入添加用户

  命令:mongo --host 127.0.0.1 --port 27017

  运行脚本添加超级管理员

  角色参考:内置角色 - MongoDB 手册 v7.0

use admin

db.createUser({
  user: "admin",
  pwd: "123456",
  roles: [
    { role: "root", db: "admin"}
  ]
});

 4、使用Navicat登陆

   

 

posted on 2024-08-17 12:22  H__D  阅读(66)  评论(0编辑  收藏  举报