Managing a ServerPilot Server over Command-line Interface

rehmatworks profile image Rehmat Alam ・3 min read

When it comes to server management tools, ServerPilot is my favourite option. I stopped using cPanel almost 4 years ago and switched to ServerPilot. Since then, I'm loving it.

ServerPilot offers a minimalist web UI where you can manage your web apps, databases and other related stuff. But recently, I felt the need of a CLI program to manage a ServerPilot-provisioned server as I love CLI to manage servers. So to achieve that goal, I've written a Python package called SPSuite that you can use in order to manage a server that you have provisioned using ServerPilot.

How to Install SPSuite?

The package is available at GitHub at this URL. You can install it from the source code or you can use PIP to install from PyPi repository directly.

To install using PIP, execute the following command in your terminal after signing into your ServerPilot-provisioned server as root:

pip3 install spsuite

Once the package is installed, a command spsuite will become available to you. Type spsuite -h to see all available commands. Here is the list of sub-commands currently available on spsuite:

Sub-command Details
listsysusers Show all SSH users existing on this server.
createsysuser Create a new SSH user.
listapps Show all existing apps.
createapp Create a new app.
updatedomains Update an apps' domains and recreate vhost files.
changephp Change PHP version of an app.
changephpall Change PHP version for all apps.
deleteapp Delete an app permanently.
delallapps Delete all apps permanently.
listdbusers Show all existing database users.
createsqluser Create a new MySQL user.
updatesqlpassword Update any MySQL user's password.
dropuser Drop a MySQL user.
dropallsqlusers Drop all MySQL users except system users (root, sp-admin, debian-sys-maint, mysql.session, mysql.sys).
listdbs Show all existing databases.
createdb Create a new MySQL database.
dropdb Drop a MySQL database.
dropalldbs Drop all databases except system databases (information_schema, mysql, performance_schema, sys).
getcert Get letsencrypt cert for an app.
getcerts Get letsencrypt certs for all apps.
removecert Uninstall SSL cert from an app.
removecerts Uninstall SSL certs for all apps.
forcessl Force SSL certificate for an app.
unforcessl Unforce SSL certificate for an app.
forceall Force HTTPs for all apps.
unforceall Unforce HTTPs for all apps.
denyunknown Deny requests from unknown domains.
allowunknown Allow requests from unknown domains.


To create a new web app, execute this command:

spsuite createapp --name myapp --user rehmat --domains mysite.example,www.mysite.example

Above command will create a ServerPilot app with name myapp under the SSH user rehmat with domains mysite.example and www.mysite.example. If the SSH user doesn't exist, it will be created first. Latest PHP version will be used. If you need to use a specific PHP version for the web app, you can pass the version with --php flag.

Things to Remember

Please note that this tool doesn't rely on ServerPilot in order to manage a server once it's provisioned. As it works independently, the web apps, databases, SSH users and other data doesn't get stored in ServerPilot servers thus the data created using this app is not available in your ServerPilot web UI.

You can even delete your server from ServerPilot after it's initial configuration and spsuite will let you manage your server. This way, you can use ServerPilot to provision your server securely and then you can delete the server from ServerPilot and use spsuite onward to avoid ServerPilot recurring fee. But I don't recommend that. I have written this utility to allow users to manage their ServerPilot servers over CLI and my intention is not to offer the users a way to bypass ServerPilot fee.

If you face any issues while using this package, you can ask me in comments and I'll be glad to help. Moreover, don't forget to star my GitHub repository if you found this tool helpful.


Editor guide