0

Command is as below, which is executed on wind river linux manchine.

useradd vpatest -c Pav -g guest -G log -s /data/bin/cli.sh -p $6$cem^CM38$4YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1

In the /etc/shadow file it is writing only

YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1 and truncating $6$cem^CM38$4

Any way to avoid this and write the full password? I will get encrypted password and need to write as it is in the shadow file. Otherwise, is any other utilities that can be used?

2
  • can you use it inside ''? Dec 21, 2017 at 10:08
  • well, $6 and $4 are positional parameters, and $cem is a valid variable, so they'll be expanded by the shell. Though ^ isn't a valid part of a variable name, so I can't see why the ^CM38 part would disappear. Put the string in single quotes to prevent the parameter expansion.
    – ilkkachu
    Dec 21, 2017 at 10:21

1 Answer 1

2

Since your input string (password) contains characters that can be interpreted by the shell to have a special meaning (for ex. $), wrap the password string inside a pair of '', like

 useradd vpatest -c Pav -g guest -G log -s /data/bin/cli.sh -p '$6$cem^CM38$4YdQAPgu8EXNG3ecurYk4eN1sIiYNauBdHFRJew3l/Xa8PyOjACD1xNDhoocVwBzBUN9BlTXXJ/oiWHwV.fhL1'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .