使用history环境变量提升系统安全性
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用history环境变量提升系统安全性相关的知识,希望对你有一定的参考价值。
1) 应用场景
系统如果被黑客攻入,他就可以查看一下histroy就能知道了系统的一些敏感信息,像登录的密码之类的:比如有马虎的维护工程师,直接输入了数据库的密码:
[[email protected] ~]# history 16 history 17 clear 18 mysql -u root -p‘redhat12345‘ -S /data/3306/mysql.sock 19 history 如上,我们可以发现数据库的密码为redhat12345
2)如何让系统不记录这些敏感信息了?
[[email protected] ~]# export HISTCONTROL=ignorespace [[email protected] ~]# history 16 history 17 clear 18 mysql -u root -p‘redhat12345‘ -S /data/3306/mysql.sock 19 history 20 export HISTCONTROL=ignorespace 21 history 22 clear 23 history [[email protected] ~]# who am i root pts/0 2016-10-14 21:13 (10.10.10.1) [[email protected] ~]# mysql -u root -predhat12345 -S /data/3306/mysql.sock -e "show databases;" +--------------------+ | Database | +--------------------+ | information_schema | | blog | | dawnpro | | eip | | ems | | hangzhou_dawnpro | | james | | kitty | | mysql | | opark | | performance_schema | | test123 | | wanlong | | www | +--------------------+ [[email protected] ~]# w 03:19:43 up 1 day, 21:26, 2 users, load average: 1.00, 1.00, 1.00 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT root pts/0 10.10.10.1 21:13 0.00s 0.76s 0.01s w root pts/1 10.10.10.1 03:03 14:32 0.19s 0.19s -bash [[email protected] ~]# history 16 history 17 clear 18 mysql -u root -p‘redhat12345‘ -S /data/3306/mysql.sock 19 history 20 export HISTCONTROL=ignorespace 21 history 22 clear 23 history 24 who am i 25 w 26 history 如上可知,“空格+命令”,可以不让histroy记录这些敏感信息
3)其它方法
输入重要命令前,先输入export HISTIGNORE=*,然后输入重要命令,输入完成后,再通过"export HISTIGNORE=”恢复记录 [[email protected] ~]# history -c [[email protected] ~]# export HISTIGNORE=* [[email protected] ~]# mysql -uroot -predhat12345 -S /data/3306/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 65 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> \q Bye [[email protected] ~]# export HISTIGNORE= [[email protected] ~]# history 16 export HISTIGNORE=* 17 history
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1863018
以上是关于使用history环境变量提升系统安全性的主要内容,如果未能解决你的问题,请参考以下文章