Isso deve fazer isso
#!/bin/bash
#Run ./x.sh username password
crypting='perl -e 'printf("%s\n", crypt($ARGV[0], "password"))' "$2"'
useradd -m -p $crypting -s /bin/bash $1
Eu fiz algo assim há um tempo atrás, quando estava entediado
#!/bin/bash
#Run ./y.sh username password
crypting=$(perl -e 'print crypt($ARGV[0], "password")' $2)
randomid=$(echo $[ 1000 + $[ RANDOM % 10000000 ]])
mkdir /home/$1
echo "$1:$crypting:16760:0:99999:7:::" >> /etc/shadow
echo "$1:$crypting:$randomid:$randomid:$1:/home/$1:/bin/bash" >> /etc/passwd