Introduction:
Encountering the “su: cannot open session” error in CloudLinux can be frustrating, but fear not! This tutorial will guide you through the process of identifying and correcting the ownership of files and folders under the user’s .cagefs directory, allowing you to establish a shell session successfully.

Symptoms:
You may come across this error when attempting to switch to a user’s shell:

[root@server ~]cPs# su -l cpusername -s /bin/bash
Error: user or UID cpusername does not exist 
su: cannot open session: Cannot make/remove an entry for the specified session

Additionally, you might notice files or folders under the cPanel user’s .cagefs folder that are not owned by the cPanel user.

Description:
This issue arises when files or folders under the .cagefs directory have incorrect ownership, hindering the establishment of a shell session.

Workaround:
Follow these simple steps to fix the ownership issue:

  1. Access the server’s command line as the ‘root’ user via SSH or “Terminal” in WHM.
  2. Run the following command to locate files and folders not owned by the cPanel user and correct the ownership. Ensure to replace “$cpusername” with the cPanel user’s username:
user="$cpusername"; find /home/$user/.cagefs -path /home/$user/.cagefs/tmp -prune -o ! -user $user -exec chown $user. {} \;

Explanation:

  • The find command is used to search for files and folders under the .cagefs directory.
  • The -path /home/$user/.cagefs/tmp -prune option excludes the tmp folder from the search, as it contains socket files that should not be owned by the cPanel user.
  • The ! -user $user -exec chown $user. {} \; part identifies files and folders not owned by the cPanel user and corrects the ownership using the chown command.

Conclusion:
By following these straightforward steps, you can resolve the “su: cannot open session” error in CloudLinux caused by incorrect ownership. Remember to replace “$cpusername” with the actual cPanel user’s username. This quick workaround ensures a smooth experience when switching to a user’s shell. If you encounter any issues, feel free to seek further assistance from your server administrator or support team. Happy shell session fixing!

Categorized in:

cPanel/WHM, Server Management,

Last Update: December 10, 2023