iWhost Pakistan provides complete management to customers for Dedicated Servers and VPS. But many customers who have unmanaged vps asked us that how can they easily secure tmp directory on OpenVZ VPS and cPanel.
The tmp directory is used by scripts to hold temporary data however malicious scripts can use tmp directory in wrong way. You can fix this by creating /tmp partition. In this way you can block malicious script execution.
Securetmp Script of cPanel
You can not run /scripts/securetmp on OpenVZ VSP and if you try you will get error like:
the loop module wasn’t detected/installed
but there is another easy way to secure /tmp directory
Edit /etc/fstab
You have to edit /etc/fstab in any editor and add following line in bottom and save it.
none /tmp tmpfs nodev,nosuid,noexec 0 0
Now a reboot will be needed but for those who don’t like reboot can mount /tmp in another way
Mount /tmp
Instead of rebooting VPS you can mount /tmp by running following command
mount -t tmpfs -o noexec,nosuid tmpfs /tmp
Verification
Run the following command will confirm you that /tmp directory is now secured by showing /tmp directory with “tmpfs”
df -h
In case of any query, please feel free to contact our web hosting support.