Last update at :2024-06-30,Edit by888u
Today I saw an article about the security issues of .bash_history files in Linux VPS which still need to be handled with caution. Because after any of our SSH command operations, a record will be left in the .bash_history file. If the file is leaked for some reason, the permissions of the website and VPS can be obtained. Therefore, I searched for relevant articles at night to solve and deal with the safe handling of .bash_history files.
First, the path to the .bash_history file
You can see a .bash_history file in the root directory of any Linux VPS host ROOT, which is 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 clear the files after launching the VPS.
Second, how to clear the .bash_history file
A – Clear directly with command
cat /dev/null > ~/.bash_history && history -c && exit
You can execute the command to clear the file before exiting the VPS and clear the file to exit.
B – Reduce the number of saved items
Modify the HISTSIZE entry in the /etc/profile file. The default number is 1000. We can modify it to 5 or 10 or less, so that fewer records will be saved.
Then in the \\"/etc/skel/.bash_logout\\" file, add a line \\"rm -f $HOME/.bash_history\\" so that the file will be cleared after the user logs out of the VPS.
The above is about the information that was found and compiled after recording the content in the .bash_history file. If any friends see it, they can add it accordingly.
Recommended site searches: IP search, virtual host Linux Dongguan server rental, Qingdao IP proxy, how to check IP address, independent IP space, cheap domain name, dual-line server, domain name registration website, hosting space,
发表评论