Skip to main content

VPS/WHM/cPanel permissions problem

Comments

3 comments

  • chrisbuk
    Hi SSH to your server to / directory type: nano fixperms.sh paste: [QUOTE]#!/bin/bash if [ "$#" -lt "1" ];then echo "Must specify user" exit; fi USER=$@ for user in $USER do HOMEDIR=$(grep $user /etc/passwd | cut -d: -f6) if [ ! -f /var/cpanel/users/$user ]; then echo "$user user file missing, likely an invalid user" elif [ "$HOMEDIR" == "" ];then echo "Couldn't determine home directory for $user" else echo "Setting ownership for user $user" chown -R $user:$user $HOMEDIR chmod 711 $HOMEDIR chown $user:nobody $HOMEDIR/public_html $HOMEDIR/.htpasswds chown $user:mail $HOMEDIR/etc $HOMEDIR/etc/*/shadow $HOMEDIR/etc/*/passwd echo "Setting permissions for user $USER" find $HOMEDIR -type f -exec chmod 644 {} \; -print find $HOMEDIR -type d -exec chmod 755 {} \; -print find $HOMEDIR -type d -name cgi-bin -exec chmod 755 {} \; -print find $HOMEDIR -type f \( -name "*.pl" -o -name "*.perl" \) -exec chmod 755 {} \; -print fi done
    then control+X to close, and Y to save. then whenever you have permissions problems just ssh to server and type: sh fixperms.sh USERNAME (replace USERNAME with the username of the Cpanel user with the issue) this will fix the permissions of the users account.
    0
  • cPanelMichael
    Hello :) Please keep in mind that it's not always a good idea to change ownership of all your home directory files to the account username. Some files may have ownership set to another value on purpose. Instead, access your server via SSH as root, and check the ownership values on the following directories and files within them: /home/$username Are any of these files owned by "root"? Thank you.
    0
  • pagchen
    [COLOR="#FF0000">BEWARE! This script will change the file permissions of files like .htpasswds in /home/username/ to less secure 0655. I think it would be better if the last "find" commands run only in $HOMEDIR/public_html folder. Even then as stated by CpanelMichael, it can put files that needs more secure permissions to less secure permissions inside the public_html folder.
    0

Please sign in to leave a comment.