Introduction:
Note: 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.
Procudure:
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 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@test-001.net: ~ /scripts/whmlogin
https://10.2.32.33:2087/cpsess5251595412/login/?session=root%3a45ka3zvKCQIcwkKp%3acreate_user_session%2cf2c773013421531458e7aab5fbe30d1f368c
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.
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://10.2.32.33: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 test@cptest.tld
with the account for which you wish to create the temporary URL):
whmapi1 create_user_session user=test@cptest.tld service=webmaild
Comments
0 comments
Article is closed for comments.