AdminsForum

CloudPanel CLI (clpctl) & Automation Guides

Guide CloudPanel: getting started with the clpctl command

Started by JAY 0 replies 323 views
1JAY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
CloudPanel: getting started with the clpctl command

CloudPanel comes with clpctl, a command-line tool for jobs you'd otherwise click through in the browser. You don't need it for everyday work, but it's the tool that saves you when the web interface is out of reach, and it makes repeat jobs fast and identical every time. This guide explains how clpctl is organised, how to explore it safely and which commands are worth knowing first. For a full list, keep the clpctl cheat sheet open.

Two kinds of commands: root and site user
clpctl has two groups of commands, and which user you are decides which ones work:
  • Root user commands manage the whole server: sites, panel users, databases, certificates, vhost templates and panel security. Log in over SSH as root for these.
  • Site user commands work inside one site: resetting file permissions, exporting and importing that site's databases, and purging its Varnish cache. Log in as the site user, or switch from root with
    Code:
    su - siteuser
    .
Using the wrong user is the most common reason a command "doesn't work". More on that in clpctl errors: command not found, wrong user and quoting.

Explore without changing anything
List every command available to the current user:
Code:
clpctl list
Show the options of one command before you run it:
Code:
clpctl site:add:php --help
Commands are named
Code:
area:action
(for example
Code:
db:export
or
Code:
lets-encrypt:install:certificate
), and options use camelCase:
Code:
--domainName
,
Code:
--databaseName
,
Code:
--userName
.

Safe commands to try first
These only read information, so they're a good way to get comfortable. As root:
Code:
clpctl user:list clpctl vhost-templates:list clpctl db:show:master-credentials
The last one prints the database master login. Treat its output like a password: don't paste it into tickets or forum posts.

As a site user, inside the site folder, a harmless one is purging the site's cache:
Code:
clpctl varnish-cache:purge --purge=all

Commands worth knowing for emergencies
  • Lost the panel password:
    Code:
    clpctl user:reset:password --userName='john.doe' --password='New-Strong-Pass'
  • Lost your 2FA device:
    Code:
    clpctl user:disable:mfa --userName='john.doe'
  • Locked out by panel Basic Auth:
    Code:
    clpctl cloudpanel:disable:basic-auth
  • Messed-up file permissions (as the site user, in the site folder):
    Code:
    clpctl system:permissions:reset --directories=770 --files=660 --path=.
Step-by-step help for lockouts: Can't log in to CloudPanel?

Good habits
  • Put option values in single quotes, especially passwords with
    Code:
    !
    or
    Code:
    $
    in them.
  • Take a snapshot or backup before commands that change or delete things (
    Code:
    site:delete
    ,
    Code:
    db:import
    ).
  • Try new commands on a test site first.
  • When you script clpctl, log the output so you can see failures later.

Sources: CloudPanel: root user commands · CloudPanel: site user commands
Reply
Possibly Related Threads…matched by title
Replies:0Views:263
Replies:0Views:322

Users browsing this thread: 1 Guest(s)
Forum Jump: