If you want to restrict consecutive characters on the keyboard to no longer than 4 characters, then used pam_cracklib module. Read his manual https://linux.die.net/man/8/pam_cracklib
next params can you help: maxsequence=N