This article will explain how to generate a Single-use Auto-Login URL For WHM from server SSH or terminal /Putty.

Root SSH access to the server is required in order to run any of the following commands.

There are quite a few occasions where you might need to generate a one-time login URL (AKA a login session) to any of the cPanel-related interfaces (WHM/cPanel/Webmail). You might have lost your password and need to log into the interface to reset the password.

There are times where you might need to provide a developer login access, but you want the access to be only an one-time access. And many other situations where having the capability to generate a temporary user session would come in handy. This capability is built into your cPanel installation and can be achieved in quite a few different ways. Here we will discuss the most convenient ways to achieve such a task.

Steps: Single-use Auto-Login URL For WHM

The WHM Interface: 

There are two ways to create a temporary user session to the WHM interface. For the first one, you need to log into the cpanel hosting server via SSH as the root user and run the following command:

/scripts/whmlogin

This script will generate a temporary login URL to the WHM interface. The output looks like this:

[root@nstest ~]# /scripts/whmlogin
https://nstest.com:2087/cpsess7282232754/login/?session=root%3aHak9mOuaQmg_Y1B1%3acreate_user_session%2c43f4f05df97418b78c1bbb962e06c000
[root@nstest ~]#

You need to copy and paste the above URL into the browser’s search bar and then you will be able to log into the WHM interface directly without having to enter any login credentials.

Single-use Auto-Login URL For WHM

Alternatively, you can use the create_user_session API function call to achieve the same:

whmapi1 create_user_session user=root service=whostmgrd

---
data:
cp_security_token: /cpsess0757885636
expires: '1604928498'
service: whostmgrd
session: root:cViC4b9uttvOWMUW:create_user_session,d9ed611d46eb58c80e2add6c5ef2963b
 url: https://10x.xx.xx.xx:2087/cpsess0757885636/login/?session=root%3acViC4b9uttvOWMUW%3acreate_user_session%2cd9ed68c80e2add6c5ef2963b
metadata:
command: create_user_session
reason: Created session
result: 1

Here you can use the URL outputted (highlighted) when the above command is executed.

The cPanel Interface: 

Similarly, for the cPanel and the Webmail interfaces, we can use the above API call to generate the temporary URL: (Here you need to replace the cPanel user cptest with the user for whom you wish to create the temporary URL)

whmapi1 create_user_session user=cptest service=cpaneld

The Webmail Interface: 

(You need to replace the email account [email protected] with the account for which you wish to create the temporary URL):

whmapi1 create_user_session [email protected] service=webmaild

From the above post you know how to create Single-use Auto-Login URL For WHM from SSH or terminal.

To understand and know how to save individual email in cPanel webmail clickhere