+ Reply to Thread
Results 1 to 2 of 2




  

Thread: Secure temp on cPanel servers

      
  1. #1
    Will Work For Coffee :-} Big Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond repute Big Dan's Avatar
    Join Date
    October 14, 2006
    Location
    New York
    Posts
    1,954
    Rep Power
    8
    Feedback Score
    0

    Exclamation Secure temp on cPanel servers

    The first step is to check if /tmp is already secure. Some datacenters do not create a /tmp partition while others do.
    -----command-----
    df -h |grep tmp
    -----command-----


    If that displays nothing then go below to create a tmp partition. If you do have a tmp partition you need to see if it mounted with noexec.
    -----command-----
    cat /etc/fstab |grep tmp
    -----command-----

    If there is a line that includes /tmp and noexec then it is already mounted as non-executable. If not follow the instructions below to create one without having to physically format your disk. Idealy you would make a real partition when the disk was originally formated, that being said I have not had any trouble create a /tmp partition using the following method.

    Create a 190Mb partition
    -----command-----
    cd /dev/; dd if=/dev/zero of=tmpMnt bs=1024 count=200000
    -----command-----

    Format the partion
    -----command-----
    mke2fs /dev/tmpMnt
    -----command-----
    When it asks about not being a block special device press Y


    Make a backup of the old data
    -----command-----
    cp -Rp /tmp /tmp_backup
    -----command-----

    Mount the temp filesystem
    -----command-----
    mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp
    -----command-----

    Set the permissions
    -----command-----
    chmod 0777 /tmp
    -----command-----

    Copy the old files back
    -----command-----
    cp -Rp /tmp_backup/* /tmp/
    -----command-----

    Once you do that go ahead and restart mysql and make sure it works ok. We do this because mysql places the mysql.sock in /tmp which neeeds to be moved. If not it migth have trouble starting. If it does you can add this line to the bottom of the /etc/fstab to automatically have it mounted:

    Open the file in pico:
    -----command-----
    pico -w /etc/fstab
    -----command-----
    Now add this single line at the bottom:

    /dev/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0

    While we are at it we are going to secure /dev/shm. Look for the mount line for /dev/shm and change it to the following:
    none /dev/shm tmpfs noexec,nosuid 0 0

    Umount and remount /dev/shm for the changes to take effect.
    -----command-----
    umount /dev/shm
    mount /dev/shm
    -----command-----

    Next delete the old /var/tmp and create a link to /tmp
    -----command-----
    rm -rf /var/tmp/
    ln -s /tmp/ /var/
    -----command-----

    If everything still works fine you can go ahead and delete the /tmp_backup directory.
    -----command-----
    rm -rf /tmp_backup
    -----command-----
    Big Dan
    DJ Talk - Where DJ's meet! | Almost Geek - Geeky Tutorials and Stuff | Got Email Questions?

  2. #2
    minus19
    Forum Guest

    Default

    Or you can just run this

    /scripts/securetmp

    cPanel - The Leading Control Panel

    Though you're method will always work, where as the CP script doesn't

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. block the spam on ur servers , secure ur server from sending spam
    By sparks man in forum Dedicated / VPS Hosting
    Replies: 4
    Last Post: May 2nd, 2008, 2:38 pm
  2. Secure Server Certificates SSL
    By grim in forum General Business
    Replies: 22
    Last Post: May 2nd, 2008, 6:36 am
  3. Secure email
    By Brianlan in forum Internet
    Replies: 0
    Last Post: Feb 3rd, 2008, 12:27 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads