I am trying to automate creating linux users using bash
# Below password does NOT work
#USER_PASS="Eb*rx>BN?3x3SKd"
# Below password works!
USER_PASS="qwer1234"
# 2: Create sample user and set password
USER="sampleuser"
ssh root@$HOST "useradd -m $USER -s /bin/bash"
ssh root@$HOST "echo $USER:$USER_PASS | chpasswd"
ssh root@$HOST 'cat /etc/passwd'
echo "test ssh login with $USER"
sshpass -p $USER_PASS ssh $USER@$HOST
The above works fine when I use the 'qwer1234' password but does not work when I use the other one starting with 'Eb*'.
Are there any rules for linux passwords, characters etc.?
ssh root@$HOST "echo $USER:$USER_PASS | chpasswd"
. There's now a fileBN?3x3SKd
there and it's content issampleuser:Eb*rx
. It's because of>
.Eb*rx>BN?3x3SKd
as unquoted string so*
and?
may trigger shell globbing.