Hey everyone,
This is a quick tutorial on securing your server against unwanted and dangerous access.
By default, it is very easy to access a server's /var/tmp and run some nasty executables. This guide will help you to stop that. Not many people actively do this when securing their servers but it is a necessity to ensure security.
As with any other guides I write, I try to keep it short and too the point, with more tags than general text ;-)
So, onwards!
##########Part 1, deleting and symlinking /var/temp##########
1. SSH in to your server
-
Code:
SSH [-p port] user@host/ip
2. Remove /var/tmp
3. Symlink (symbolic link) it to /tmp
Code:
ln -s /tmp /var/tmp
##########Part 2, mounting /tmp as a separate filesystem##########
1. Backup your fstab
Code:
cp /etc/fstab /etc/fstab.bak
2. Create a 1GB temp mount partition
Code:
dd if=/dev/zero of=tmpMnt bs=1024 count=1048576
3. Format the new partition
Code:
mkfs.ext3 -j /var/tmpMnt
*Answer "Y" when asked.
4. Backup the old /tmp
Code:
cp -Rp /tmp /tmp_backup
5. Mount the new /tmp filesystem
Code:
mount -o loop,noexec,nosuid,rw /var/tmpMnt /tmp
6. Set the necessary permissions
7. Copy files back to /tmp [code]cp -Rp /tmp_backup/* /tmp/ [/code] *Code tags decided not to work here. Don't miss it!*
8. Add new /tmp to fstab
Code:
echo “/var/tmpMnt /tmp ext3 loop,rw,noexec,nosuid,nodev 0 0″ >> /etc/fstab
And there you go. Your server is now a lot more secure than it was before and chances are, you'v learnt a couple new commands!
Cheers,
-Pulser