# Manually Hash Passwords

## Inimi

Hi all,

This topic has cost me about 2 hours of search and no solution in sight for gentoo.

How do I generate the password hashes manually from the password to be able to enter it in /etc/shadow????

Examples what I tried:

echo "password" | md5sum

don't work

makepasswd --crypt (--crypt-md5 does not exist)

don't work

slappasswd

don't work

Any ideas??

Have a nice day

Günther

----------

## John R. Graham

My advice is, "Use the source, Luke."  Take a likely utility that does the manipulation, say, "passwd", and find out what package it's part of:

```
# equery belongs `which passwd`

[ Searching for file(s) /usr/bin/passwd in *... ]

sys-apps/shadow-4.0.18.2 (/usr/bin/passwd -> /bin/passwd)
```

Then unpack the source code:

```
# ebuild /usr/portage/sys-apps/shadow/shadow-4.0.18.2.ebuild unpack
```

And, voila!  You've got a full set of source  in "/var/tmp/portage/sys-apps/shadow-4.0.18.2/work".

- John

----------

## Inimi

k, thx for this tip.

But is there not a dedicated utility for that available?

Have a nice day

Günther

----------

## djinnZ

I not remeber esactly what is the method but at the password MD5 checksum will be added some "salt" (related to the creation date) to prevent an easy dictionary attack.

The only way is to inspect the code of shadow package to be sure. Or waiting from someone that remember what do.

----------

## Inimi

I read the code.

Perhaps I'm writting an utility which does that.

Or I could extend passwd but with another update it is gone.

thx for your help

have a nice day

Günther

----------

## Inimi

Hi got the solution:

```

openssl passwd -1 "secret"

```

----------

## krasko

or

mkpasswd --hash=md5 --salt=$salt $password

$salt = 8 digs lenght (best random) strinnng

$password = password to hash

salt md5 is used in /etc/shadow (/etc/passwd) looks $1$SALT$HASH

----------

