Within some shared-hosting policies, cPanel terminals may be disabled by default for all users. However there are different solutions to explicitly activate it for specific users based, for example, on their e-mails.
Following is a fast made command:
egrep "user@example.com" /var/cpanel/users/* | cut -f1 -d: | cut -f5 -d\/ | while read line; do [ "$(egrep $line /etc/passwd | egrep -c bash)" -eq "0" ] && whmapi1 modifyacct user=$line HASSHELL=1; doneWe can generalize it as a script by setting all the e-mails we want to allow in a text file i.e. usersToAllowShellFor.txt (line by line)
#!/bin/bash
# This script enables shell access for all user accounts whose email addresses
# are listed in the file 'usersToAllowShellFor.txt'.
# Each email address should be on a separate line in the file.
while read userEmail; do
egrep "$userEmail" /var/cpanel/users/* | cut -f1 -d: | cut -f5 -d\/ | while read line; do
[ "$(egrep $line /etc/passwd | egrep -c bash)" -eq "0" ] && whmapi1 modifyacct user=$line HASSHELL=1
done
done < usersToAllowShellFor.txtWhich can then be programed as a cron or used as a hook when a new account is created, etc:
0 2 * * * /scripts/AutoEnableShell.sh
Comments