Q: When I create a new user in Red Hat, how can I force this user to change their password the first time they log on via ssh?

A: Using a few well known commands, we can make sure the user is forced to change their password upon first login.  For this example we will use both the usermod command and the chage command.

Here are the three steps I would take to force a user to change their password on next login.  For this example we will use your name as an example user account.

First we create the account:

useradd haden

Then we set a password for the account:

passwd haden

Then we force the password to expire:

usermod -L haden
chage -d 0 haden
usermod -U haden

This effectively locks the users password.  Then we use the chage command the change the age of the password to 0 (forcing a password change), then we unlock the account allowing the user to log in with their old password one last time.

Anyone is welcome to post in the comments how they accomplish this same task. We love to hear different ways to accomplish the same task.

Helpful Links