记一次阿里云上Redis服务器被入侵的经历

来源:互联网 发布:ubuntu 在线音乐 编辑:程序博客网 时间:2024/06/08 06:54

记一次阿里云上Redis服务器被入侵的经历

自己做的练手的项目部署在阿里云上,安装了Redis-server,为了在本地调试方便,在/etc/redis/redis.conf 里quote bind 127.0.0.1之后。没有设置 requirepass,结果就是在我的服务器上线几天之后被某些无聊的人扫描6379端口,试图植入挖矿程序(minrd),同时清空了我redis数据库中的所有数据。详情可参考两篇博客 莫失莫忘的博客 redis被黑。
好在我的Redis是以redis用户运行,当然不能是root啦!所以ssh key没有被修改,只是丢失了几个我随便输入的键值对。
在此,也提醒各位自己玩阿里云之类服务器的童鞋,不要图方便,又不设置密码。顺带提醒下Redis官方注释也提醒我们了

 # Warning: since Redis is pretty fast an outside user can try up to # 150k passwords per second against a good box. This means that you should # use a very strong password otherwise it will be very easy to break.

咳咳,官方认为黑客可以利用Redis的高性能以15万每秒的密码组合暴力破解密码,所以密码还是尽量长一点复杂点。再最后附带我在项目中使用Spring Jedis和密码认证方式连接Redis的代码片。

    try(Jedis jedis = jedisPool.getResource()){        jedis.auth(password);        //do your things         return true;    }catch (Exception e){        return false;    }

希望能对大家有点帮助。

原创粉丝点击