3

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
# 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 '14 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. – Patrick Jun 6 '14 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 '14 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. – Gilles 'SO- stop being evil' Jun 6 '14 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. – Patrick Jun 6 '14 at 23:29
3

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.

2

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

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 '17 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.