`ktutil` is a REPL-style utility that can be controlled only interactively. The common approach of sending commands to stdin does not work with it on systems where `readline` library has version less then 8.0 due to a bug in that version. With `pexpect` we avoid this bug because it emulates the terminal when interacting with spawned process instead of simply sending all input to stdin. Related to: https://pagure.io/freeipa/issue/8690 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>