Você pode usar chpasswd
The chpasswd command administers users' passwords. The root user can supply or change users' passwords specified through standard input. Each line of input must be of the following format.
username:password Only root users can set passwords with this command.
Exemplo 1:
echo username:password | chpasswd
Exemplo 2:
Também para segurança, você pode passar senha criptografada para chpasswd
# Create Password in Encrpyted Form Using below command
# perl -e'print crypt("YourPassword", "salt")' ; echo -e
echo username:cryptedPass | chpasswd -e