1. Home
  2. Knowledge Base
  3. cPanel
  4. CLI Scripts
  5. Web Host Manager – Log in to WHM using the CLI

Web Host Manager – Log in to WHM using the CLI

Quick Start Guide

The WHM login script is an advanced option for users with expert knowledge and shell access. It requires an understanding of SSH and command-line operations.

Introduction to WHM Login Script

The “whmlogin” script offers a streamlined, secure way for system administrators to access the cPanel Web Host Manager (WHM) interface without the need for manually entering login credentials. This guide provides straightforward instructions for generating a single-use session login URL for WHM using the whmlogin script. This method enhances security and efficiency, particularly useful for those managing multiple web servers or require quick access to the WHM platform.

Steps for Quick Access

Access Your Server via SSH: Start by accessing your server using SSH (Secure Shell). Ensure you log in as the root user to proceed with the subsequent steps.

Execute the WHM Login (whmlogin) Script: Run the script by entering :

    /scripts/whmlogin

    /scripts/whmlogin in the terminal. The script will then generate a unique, single-use URL for logging into WHM.

    Log in to WHM: Copy and paste the provided URL into your browser. This will direct you straight to the WHM Home interface, bypassing the standard login procedure.

      Elevating Permissions for Non-Root Users

      If you are not logged in as the root user, you must elevate your permissions using the sudo command. Follow these steps:

      1. Log in as a Sudo User: First, access the server with your regular user account, which should have sudo privileges.
      2. Elevate to Root: Type sudo su - and enter your password if prompted. This command switches your session to the root user, allowing you to run the whmlogin script.

      In-depth Guide

      Understanding the WHM Login (whmlogin) Script

      The /scripts/whmlogin script is a powerful tool designed to simplify the process of accessing WHM, particularly for system administrators managing multiple accounts or servers. This script automatically generates a URL that leads directly to the WHM interface without requiring manual login, thereby enhancing security and efficiency.

      How the WHM Login Script Works

      When executed, the script creates a unique, single-use session URL. This URL is composed of the server’s IP address, the WHM port (2087), and a session token. The token is encrypted, ensuring that the login process is secure and can only be used once, after which it expires.

      Example Use Case

      For instance, if your server’s host name is server1.smarthostservers.ie, running the whmlogin script might produce an output similar to:

      https://server1.smarthostservers.ie:2087/cpsess1234567890/login/?session=root%3aAqI0aGGAFWI_Mab_%3acreate_user_session%2c31cd420f0fd6aca696a2890f580f2f0a

      Navigating to this URL will bypass the standard login page, taking you directly to the WHM dashboard. This method is particularly useful for administrators needing to access WHM quickly or those managing several hosting environments.

      Security Considerations

      While the whmlogin script provides a convenient and secure method to access WHM, it is crucial to follow best practices for server security. Always ensure that SSH access is restricted to authorised users and that the server is protected by a firewall. Moreover, the single-use nature of the login URL significantly reduces the risk of unauthorised access, as the URL expires immediately after use.

      By leveraging the whmlogin script, system administrators can achieve a more efficient and secure workflow, allowing for quicker access to WHM and enhancing the overall management of web hosting environments.

      FAQ – Log in to WHM from the Command Line

      What is the WHM login script?

      The WHM login script, /scripts/whmlogin, is a command-line tool that generates a single-use, secure URL for logging into the Web Host Manager (WHM) interface without the need to enter login credentials manually. This script facilitates quick and secure access to WHM for system administrators.

      How do I access my server via SSH?

      To access your server via SSH, you’ll need an SSH client. On Windows, you can use PuTTY, whereas macOS and Linux systems have built-in terminal applications for this purpose. Enter the command ssh username@your_server_ip, replacing username with your server’s username and your_server_ip with your server’s IP address. You’ll be prompted to enter your password to proceed.

      Can I use the WHM login script if I’m not the root user?

      Yes, you can use the WHM login script even if you are not logged in as the root user. However, you must have sudo privileges to elevate your permissions to root. Once logged in with your user account, use the command sudo su - to switch to the root user, allowing you to execute the whmlogin script.

      Is it safe to use the WHM login script?

      Yes, the WHM login script is safe to use. It generates a unique, single-use URL for logging into WHM, which enhances security by ensuring that the login link cannot be reused. To maintain optimal security, ensure that your server is protected by strong passwords, SSH access is restricted to authorised users, and a firewall is in place.

      What happens if I encounter an error while running the script?

      If you encounter an error while running the script, check for the following common issues:
      – Ensure you are logged in as the root user or have elevated your permissions to root using sudo su -.
      – Verify that the path to the script is correct: /scripts/whmlogin.
      – Make sure that your server is running and accessible over the network.
      If the issue persists, consult the WHM and cPanel documentation or contact SmartHost technical support for further assistance.

      How long is the generated URL valid?

      The URL generated by the whmlogin script is valid for a single use. Once you navigate to the URL and access WHM, the link expires immediately to prevent unauthorised access. If you need to access WHM again, you will need to rerun the script to generate a new URL.

      Was this article helpful?
      Go to Top