How do I secure /tmp and /var/tmp on a OpenVZ VPS?

On an OpenVZ VPS you will need to do the following to secure /tmp and /var/tmp.

Secure /tmp

  1. Edit /etc/fstab by typing the command nano -w /etc/fstab
  2. Paste the following at the bottom of /etc/stab that you just opened: none /tmp tmpfs nodev,nosuid,noexec 0 0
  3. Press ctrl + x to close the file, press y to save it.
  4. Remount /tmp by typing the following then press enter: mount -o remount /tmp
  5. You can verify that /tmp is correctly mounted by typing df -h and you should see something similar to the following: none          3.9G   0  3.9MG   0% /tmp.

Secure /var/tmp

  1. Backup /var/tmp by typing the following: mv /var/tmp /var/tmpbackup
  2. Make a symbolic link that makes /var/tmp point to /tmp by typing the following: ln -s /tmp /var/tmp
  3. Copy back the old data using the command: cp /var/tmpbackup/* /tmp/
  4. Remove the un-needed backup you created: rm -rf /var/tmpbackup

You should now reboot your VPS. This means /tmp and /var/tmp are now secured.

Was this answer helpful?

 Print this Article

Also Read

Which Operating Systems can I install?

We offer the following Linux Operating Systems / Distros on our VPS's. If you require a...

What is an unmanaged server?

An unmanaged server is where you are given full root access to the server. You are responsible...

Can I install OpenVPN on a VPS?

In short, yes you can. To install OpenVPN you will need to have TUN/TAP support enabled on your...

Can I have custom rDNS records?

We provide all our VPS customers with the ability to have custom rDNS records. To take advantage...

How do I add a cronjob?

A cronjob is used to schedule automated tasks such as running a PHP script at a set time. These...