I want to know how can I create an encrypted password in Ubuntu 14.04 LTS. Tried this:

makepasswd --crypt-md5 password_here

It did not work for me. It is throwing this Error:

sysadmin@localhost:~$ makepasswd --crypt-md5 admin123

makepasswd:  Non-argument options specified:  admin123
makepasswd:  For more information, type:  makepasswd --help

I want to add those encrypted password in one of the installation so I need the way of doing it.

5 Answers 5


Another way is this: openssl passwd -1 -stdin <<< password_here

This does not show the password on the process list. For more options see openssl passwd --help

  • 1
    It does not show password on the process list, but it can still be seen in history. I would propose something like this read -p "Enter password: " -s PASSWORD; echo; openssl passwd -1 -stdin <<< $PASSWORD.
    – nobody
    Dec 25, 2020 at 15:41
# echo -n admin123 | makepasswd --crypt-md5 --clearfrom -
admin123     $1$ZUNNSLzQ$XsViFC1bhucsr3f8AzMPt/

As commented bellow this command is unsecure. True method - write password in file with text editor, and read password from file.

  • 3
    Excuse me: add -n to echo.
    – mr_tron
    Jun 6, 2014 at 10:22
  • 4
    Note that the reason makepasswd doesn't read the password as an argument is that arguments are visible to anyone with access to the server, simply by running ps. Thus by putting it as an argument to echo, you're making it visible.
    – phemmer
    Jun 6, 2014 at 14:57
  • 3
    This answer would be greatly improved if you explained why OP's command didn't work and yours did, instead of just throwing a valid solution without an explanation. Also, @Patrick has a point, to which I would add command history.
    – Darkhogg
    Jun 6, 2014 at 15:29
  • @Patrick Passing a password as an argument to makepasswd would expose it to other users via ps, but not passing it to echo. echo is a builtin in all contemporary shells. Command history, on the other hand, is a good reason not to do it this way — alternatively, you can disable command history for the duration. Jun 6, 2014 at 22:58
  • Was wondering when someone was going to call me out on that. Yes, in almost all cases it is. But it's not a habit I would encourage as it's not guaranteed.
    – phemmer
    Jun 6, 2014 at 23:29

Your method doesn't work because makepasswd doesn't accept a password as argument, you should create a temporary clear text file instead to make the password if you want to generate the hash based on a password:

➜  ~  makepasswd --crypt-md5 --clearfrom file
admin123   $1$iQd/ujH.$rMXZiYwQC1Rc/rgO3.FeX/  

Of course, do not use the command line to store the password as it will be accessible by anyone that can read your command history or process arguments.


Just run:

openssl passwd -6 -stdin

and then type/paste your password, then ENTER, then Ctrl+D ("end of file"). No password will be seen in process list and no password will be saved into shell history.

See more password algorithms with:

 % openssl passwd -help    
Usage: passwd [options]
Valid options are:
 -help               Display this summary
 -in infile          Read passwords from file
 -noverify           Never verify when reading password from terminal
 -quiet              No warnings
 -table              Format output as table
 -reverse            Switch table columns
 -salt val           Use provided salt
 -stdin              Read passwords from stdin
 -6                  SHA512-based password algorithm
 -5                  SHA256-based password algorithm
 -apr1               MD5-based password algorithm, Apache variant
 -1                  MD5-based password algorithm
 -aixmd5             AIX MD5-based password algorithm
 -crypt              Standard Unix password algorithm (default)
 -rand val           Load the file(s) into the random number generator
 -writerand outfile  Write random data to the specified file

You can instead use AES(Advanced Enryption Standard) Algorithm, which is open source and comparatively much secured to encrypt your password.

references: https://www.aescrypt.com/

  • Even if the names are similar, crypt does not encrypt passwords as aescrypt encrypt files. Aescrypt cannot be used to transform passwords to be used in ubuntu.
    – Stephan B
    Apr 26, 2017 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.