I tried to create a user with password via ssh (with root permission) like this:
ssh root@123.45.6.7 useradd -p $(openssl passwd -1 1234) newuser
By doing so, I could successfully create an account named newuser
, but I couldn't login with the expected password (which is 1234
)
It makes no difference if I add double quotes:
ssh root@123.45.6.7 "useradd -p $(openssl passwd -1 1234) newuser"
And then I was wondering if I can generate hashed password and save it as a variable locally, but still with no luck.
password=$(openssl passwd -1 1234)
ssh root@123.45.6.7 "useradd -p $password newuser"
Is there something that I miss? Thanks in advance!