Just run the command
echo user:password | chpasswd
Note that user and password should be in plain text