Run root script using the cPanel API with 2FA enabled issue

kristofferR

Member
Oct 20, 2012
6
0
1
cPanel Access Level
Root Administrator
I enabled 2FA and for the most part it worked great, except that it broke my Letsencrypt script found here:
[How-To] Installing SSL from Let's Encrypt

Nevermind the script (since it's unofficial cPanel naturally won't/can't/shouldn't support it), but the authentication method it is using is directly copy-pasted from their documentation. It's using the Access Hash authentication
Guide to API Authentication - Software Development Kit - cPanel Documentation

It worked fine with 2FA disabled, but with 2FA enabled the output from the "print $response->content;" after it tried to install the certificate is just the html for the two-factor auth WHM page, indicating that it needs the six digit 2FA code to authenticate correctly.

I obviously can't input the 2FA six-digit security code for a crontab script that will run automatically at set intervals, so the 2FA auth example code they have on that documentation page is a no go.

Do I have to chose between using the cPanel API in scripts vs 2FA security or is there a way to bypass the need to input the 2FA security code for scripts accessing the cPanel API running on my server?
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
308
cPanel Access Level
Root Administrator
In cPanel & WHM version 54 you have to choose between 2FA and your app. Version 56 comes with some improvements to 2FA that make it possible/easier to use with custom apps.