Ubuntu checks new passwords with pam_pwquality, and its rules live in a plain config file. I’d rather set a long minimum there than a list of character class rules.
Install the module if it isn’t there yet, then add your own drop-in file:
sudo apt install libpam-pwquality
sudo mkdir -p /etc/security/pwquality.conf.d
printf 'minlen = 14\ndictcheck = 1\nenforce_for_root\n' | sudo tee /etc/security/pwquality.conf.d/50-local.conf
minlen is the minimum length; the default is 8 and it can’t go below 6. Before you raise it, check that the dcredit, ucredit and similar values are 0, the default on current versions. A positive credit lets each digit or capital count as an extra character, which makes a short password look longer than it is. dictcheck rejects passwords that match a dictionary word through cracklib, and it is on by default. enforce_for_root makes the rules apply when root changes a password too; without it root only gets a warning.
Test it right away with passwd on a test account and try something weak like summer2026.
Files in pwquality.conf.d are read in sorted order, and a later file overrides an earlier one for the same setting. These rules only apply when a password is changed through PAM. Existing passwords stay as they are, and SSH key logins are not affected at all.
Further reading: pwquality.conf(5) manual page