Skip to main content

LogMeIn method

Comments

8 comments

  • cPanelMichael
    Hello :) You may find the following document helpful: Guide to API Authentication - Secure Remote Logins - Developer Documentation - cPanel Documentation Thank you.
    0
  • adibhanna
    these are perl scripts, i wanted to know how to achieve that using php :)
    0
  • KostonConsulting
    cPanel's LogMeIn.pm is written in Perl so you won't be able to use it in PHP. You can look at the file '/usr/local/cpanel/Cpanel/LogMeIn.pm' and re-write it's logic in PHP. It doesn't actually use any cPanel specific code, it just makes a HTTP request, looks for the security token, extracts it, and then makes the same request again with the token.
    0
  • Rajiv C.J
    Hi, I am trying to generate a link to log into whm as root. Seems like logmein module accepts username and password ( text ) . Is it possible to use access /root/.accesshash to generate this link ? Can we use access hash instead of password? I dont want the script to contain the password.
    0
  • cPanelMichael
    I am trying to generate a link to log into whm as root.

    Hello :) Have you considered using the "Single Sign On" functionality? It's documented here: Guide to API Authentication - Software Development Kit - cPanel Documentation Thank you.
    0
  • Rajiv C.J
    Hi, Thanks for the hint :) I just tried it out and looks like I need some assistance with it. I authenticated with the API with accesshash and generated the link using create_user_session. Following is the code I used. my $response = $root_ua->get("https://127.0.0.1:2087/json-api/create_user_session?api.version=1&user=root&service=whostmgrd" ); my $json_decoded_payload = decode_json($response->decoded_content()); my $session_url = $json_decoded_payload->{'data'}->{'url'}; print "Session url = ", $session_url;
    And I get a url like below https://xxxxxhostname:2087/cpsess7554037757/login/?session=root%3aTixArPKrl_3DTPpVlUNnv4liR72kFW0mm_cjME7ZSQ0pUEwC5hdOamVXCSJBww7o%3acreate_user_session%2c7e83b60ab8caae00d55e48eee5a3b5b8de74cd4e0881592bed62195abdb15ce0root@hostname
    But however when I use this link on the browser, I get the error " you must specify a user to log in" I am not sure what I have done wrong. A little help with this will be much appreciated. :)
    0
  • Rajiv C.J
    Hold on, this works without any issues in another server I tested. The 1st one I tested this was in a cpanel 11.52 server. It worked fine in a 11.54. Dont know what the issue was in the previous one, but it worked in the one I really wanted it to. So this is resolved. Thanks for suggesting the method, Michael.
    0
  • cPanelMichael
    I am happy to see it's now working as intended. Thank you for updating us with the outcome.
    0

Please sign in to leave a comment.