how to use mkpasswd to generate a password in shadow file in ubuntu 10 lucid

2

2

Today I upgrade my server to ubuntu 10 lucid, The first thing that occur to me is the new encrypted method, it's the default line

root:$6$ih6NzSZL$NuK0cjnATfIS3ets.MWM3iN3/U.sPh..USCbZ/kyOATm0hpiuZkbWhgaenNKIf23d9HTE/fKnLo0PDV1UCefu0:15333:0:99999:7:::

since it starts with $6$, I figured out it's sha-512 method, so I tried to use mkpasswd tool

mkpasswd -m sha-512 123456

so I add a new line to the shadow file

yozloy:$6$4KhKoABHknIc$KY3DBvrkLPSXBnS/NZjdxrdw2EY02fDQcclf8/B3P7ymSeCBsKWyRC.zgRcklTWwmNLplWLgcAKenFzrvq6ub0:15318:0:9999:7:::

but it doesn't work! probably dues to the salt, I don't know what it is, so I didn't specify.

mko

Posted 2011-12-25T09:50:52.403

Reputation: 869

Why do you not just add the user using adduser and set a password using passwd? – Paul – 2011-12-25T11:11:54.120

@Paul, just want to say what's going under the hound – mko – 2011-12-25T15:24:42.203

Answers

8

The salt is in the second field of the password:

$id$salt$password

So when you create your passwd, pick a salt:

mkpasswd -m sha-512 <password> <salt>

Then you'll get a line

$6$<salt>$<encrypted password>

Then you can add this to your shadow file:

yozloy:$6$<salt>$<encrypted password>:...

Ie, the salt you specify remains the same in the shadow file as when you type it on the command line

Paul

Posted 2011-12-25T09:50:52.403

Reputation: 52 173

0

Run

mkpasswd -m sha-512 12345 -S ih6NzSZL

However, be aware that the result might actually be longer the original.

Daniel

Posted 2011-12-25T09:50:52.403

Reputation: 1

Is there a quickway to check the password to see if it works? – CMCDragonkai – 2016-01-19T06:34:05.933