Score:0

Change Ubuntu server password every 7 days and do autologin

ga flag

am working on a scenario where i need to Change Ubuntu server password every 7 days and do autologin.

i tried with breaking the problem: command to create user with password:

useradd -p $(openssl passwd -1 "krspassword") krs

than using the cron to execute this every 7days

but didn't work

can some pls help.

in flag
Why don't you use key based logins?
Score:0
za flag

useradd command does not change the password, it creates a user and it fails if the user already exists. If you want to change the password of an existing user, use usermod:

usermod -p $(openssl passwd -1 "krspassword") krs

This will succeed only for existing users and fail for nonexisting.

For completeness, the "create or update" scriptlet might look like this:

PW=$(openssl passwd -1 "krspassword"); if ! usermod -p ${PW} krs > /dev/null 2>&1; then useradd -p ${PW} krs >/dev/null 2>&1; fi

It attempts to change the password and if there was no such user it creates it.

Notice that -1 (MD5) encryption is obsolete. Better use -5 (SHA256) or -6 (SHA512).

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.