Focus on cloud service provider activities
Notes on website operation and maintenance

Beware of. bash_history file security in Linux VPS system

Today I saw an article about Linux VPS .bash_history The problem of file security still needs to be handled carefully. Because after any SSH command operation, we will leave a record in the. bash_history file. If the file is leaked for some reason, we can get the permission of the website and VPS. Therefore, search for relevant articles in the evening to solve and deal with the security processing method of the. bash_history file.

First, the path of the. bash_history file

In the ROOT root directory of any Linux VPS host, you can see a. bash_history file used to record SSH tasks on the server. According to the literature, 500 commands will be recorded.

Theoretically, save as few commands as possible or empty files after VPS is launched.

Second, how to clear the. bash_history file

A - Clear with command directly

cat /dev/null > ~/.bash_history && history -c && exit

You can execute the command to empty the file and exit before you are ready to exit VPS.

B - Reduce the number of saved pieces

Modify the HISTSIZE entries in the/etc/profile file. By default, there are 1000 entries. We can modify them to 5 or 10 or fewer, so that fewer records are saved.

Then add a line "rm - f $HOME/. bash_history" to the "/etc/skel/. bash_logout" file, so that the file will be cleared after the user logs out of VPS.

The above information is about finding and sorting out the content recorded in the. bash_history file. If a friend sees it, you can add it accordingly.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Beware of. bash_history file security in Linux VPS system


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge