The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

LogMeIn method

Discussion in 'cPanel Developers' started by adibhanna, Jun 4, 2014.

  1. adibhanna

    adibhanna Registered

    Joined:
    Jun 4, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I'm trying to use the LogMeIn PHP implementation https://gist.github.com/kmark/4440574
    can anyone give me an example on how it can be used?
    i want to create a link for customers so that they will be able to login to cpanel without entering their username and password.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. adibhanna

    adibhanna Registered

    Joined:
    Jun 4, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    these are perl scripts, i wanted to know how to achieve that using php :)
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    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.
     
  5. Rajiv C.J

    Rajiv C.J Registered

    Joined:
    Jan 9, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Kochin
    cPanel Access Level:
    Root Administrator
    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.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  7. Rajiv C.J

    Rajiv C.J Registered

    Joined:
    Jan 9, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Kochin
    cPanel Access Level:
    Root Administrator
    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.
    Code:
    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
    Code:
    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. :)
     
  8. Rajiv C.J

    Rajiv C.J Registered

    Joined:
    Jan 9, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Kochin
    cPanel Access Level:
    Root Administrator
    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.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page