Sexifying WHM with XML API

Posted by Nessa | Posted in uncategorized | Posted on 07-06-2008

6

.!.

I don’t know about you other cPanel system admins out there, but I find WHM to be very useful for the more advanced and time-consuming tasks, such as installing SSL certificates. However, the easy stuff like changing an account’s package and resetting passwords is a royal pain in the ass as far as convenience is concerned when you have to log into WHM, list accounts, and make whatever change.

I recently became favorable towards the WHM XML API functionality which will let me do a majority of the everyday account-related tasks from command line without ever opening my browser, which is a lot easier when managing thousands of users across multiple servers. Below are a couple scripts I’ve put together using the XML API from a base script in the cPanel forums:

Change account password

Change account package

Both are run via command line, and the arguments passed to the PHP script as variables. For example, to change an account’s password:

./chacctpass myuser mypass1234

Customizing these scripts to perform different functions is easy via the following steps:

- change if ($argc != 3) to the number of command line arguments you wish to pass to the script plus one. In the above example there are two arguments and since the script name counts, add one and that makes 3.

- in the section where the arguments are assigned to variables (like $cpuser, etc), name your variables. The first one should have an array value of 0, then 1, 2, etc.

- edit the usage example, which will come up if the required number of arguments is not provided…you can add any text you like

- if you’re using a hash (which is more secure than user/pass authentication), go fetch your remote access key from WHM and put it in the $hash value within quotes, format intact. Otherwise, put in your WHM user’s username and password

- change the $server variable to your server’s hostname

- change $apipath to the WHM path for the function you are using. You can find a whole list of them here, and most will give you the path to use in the examples sections. In the API path, insert your variable names where the values are suppose to be. For instance:

$apiPath = “/xml-api/passwd?user=myuser&pass=mypass1234″;

Would be:

$apiPath = “/xml-api/passwd?user=$cpuser&pass=$newpass”;

In the header section, uncomment whichever $header .= “Authorization: line that matches your authentication method (user/pass or hash)

Once you’ve configured your API script, chmod to 700 and run from the command line as show in my example. It’s better to lock down the script by changing its ownership only to the user that will be using it, and not giving read, write, or execute permissions to anyone else.

Note: for these scripts to work you have to have PHP compiled with OpenSSL support, otherwise change the socket variables to http over port 2086.

WHM APF Plugin

Posted by Nessa | Posted in uncategorized | Posted on 05-06-2008

11

I’m happy to announce my first ever perl-written plugin for WebHost Manager, which was developed by myself and one of my fellow sysadmins at InMotion Hosting. The first release is available here:

Download v.1.05

Download Now

To explain a little bit of background here, many hosting companies that give some sort of **** about security will leave SSH port 22 closed except for specified IPs. Us being one of them, requests from customers for us to add their IPs to their firewalls is rather redundant when we host over 900 V-dedicated systems and 100 Dedicated boxes where customers can opt for SSH access. Therefore, I decided that it would be well worth our efforts to create a WHM plugin to allow customers to add their own IPs without ever having to contact us. I am aware that some plugin developer already has a more sophisticated APF plugin for WHM but you have to pay for it.

Requirements:

- cPanel/WHM (tested on version 11.18)

- APF 0.9 (tested on 0.9.6)

- iptables enabled and working (if you are able to restart APF without any errors, it’s probably fine)

Note: default privileges will allow anyone with WHM/reseller access to use this plugin. You can manually change this in the addon_add2apf.cgi file if you want.

Installation:

cd /usr/local/cpanel/whostmgr/docroot/cgi
wget http://v-nessa.net/wp-content/scripts/apfadd_whm_1.05.tar.gz
tar -xvzf apfadd_whm_1.05.tar.gz
rm -f apfadd_whm_1.05.tar.gz

Simple enough?

From there, load up WHM and on the left side you’ll see an option to “Add IP to Firewall” and the plugin page will give you examples of what you can add. The script is set up to allow:

Hostname – v-nessa.net
Single IP – 205.134.252.71
IP CIDR – 205.134.252.71/24
Port/IP – d=22:s=205.134.252.71
Port/CIDR – d=22:s=205.134.252.71/24

Of course, the error checking is not perfect, so just be aware of what you’re adding or you might unintentionally ‘break’ your firewall, which usually results in blocked traffic.

Eventually I’m sure I’ll end up adding the ability to manage ports and remove IPs for users with a certain access level, but currently I don’t see a need to do so because I don’t believe that non-root users should have that type of access. Note that per the readme, you can edit the addon file to limit access to users with a certain reseller ACL privilege.

Installing Firefox on Ubuntu 7.x

Posted by Nessa | Posted in uncategorized | Posted on 02-06-2008

7

.!.

I still haven’t upgraded my PC to Ubuntu 8, so I was really depressed to find out that Ubuntu 7.10 stopped at Firefox 2 and wasn’t going to be offering version 3.  I’m the laziest person on the face of the earth so I wasn’t looking forward to doing this manually, but here’s how I installed Firefox 3:

Download the Linux tarball from http://www.mozilla.com/en-US/firefox/

sudo tar -C /opt -jxvf firefox-3.0.1.tar.bz2

sudo cp -R ~/.mozilla ~/.mozillabackup

sudo apt-get install libstdc++5

cd /opt/firefox/plugins/

sudo ln -s /usr/lib/mozilla-firefox/plugins/* .

sudo dpkg-divert –divert /usr/bin/firefox.ubuntu –rename /usr/bin/firefox

sudo ln -s /opt/firefox/firefox /usr/bin/firefox

sudo dpkg-divert –divert /usr/bin/mozilla-firefox.ubuntu –rename /usr/bin/mozilla-firefox

sudo ln -s /opt/firefox/firefox /usr/bin/mozilla-firefox

All Work and No Sleep Makes Nessa a Dull Girl

Posted by Nessa | Posted in uncategorized | Posted on 01-06-2008

3

.!.

I heard some rumors that v-nessa.net is shutting down — not quite true folks…but I can tell you why my frequency of posting is amiss.   Those of you in the technology field know how it is…and in case you all haven’t been following me in Twitter and aren’t one of my designated stalkers, you probably don’t know what my schedule is like:

  • Between 8-1 Mon-Thurs I’m at school either learning about things I’m not going to use in my job field, or wallowing in a hangover that I have no idea how I got
  • Between 1-wee hours of the night Mon-Fri I’m at work listening to screaming two-year-olds otherwise known as “servers”, and racking the last two brain cells I have left on programming and troubleshooting the oddities that come along with the people that want to be difficult
  • On Sat. mornings I usually unwind in Croatan catching some waves, which, aside from rapid typing and mouse wiggling, is the only physical activity I get.  When night time falls I’m usually at the bar or having a party at my house wondering when I’m going to meet a guy that isn’t a complete asshole
  • On Sundays I devote ~2-3 hours of my time to answering the shit ton of emails I get from this website and dealing with various other projects I’m involved in
  • A couple times a month I’m asked to speak at tech, Linux, and PHP student conferences at various types of events, which would be a flattering opportunity if I was a naturally more tactful person and therefore not worried about dropping f-bombs in a room full of technology-persuing Christian undergrads

I am pretty drained though – on nights that I actually get to sleep I maybe get 4-5 hours worth, and I’ve been a bit on the cranky side lately.  I did perk up though during class while reading the Dreamhost blog

…what a bunch of silly jokes those guys are.