Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

makepasswd --crypt-md5 password_here

Did not worked for me 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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted
# 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.

share|improve this answer
3  
Excuse me: add -n to echo. –  mr_tron Jun 6 at 10:22
    
Wow Worked. Thank you so much :) –  Infected Root Jun 6 at 10:24
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 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 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 Jun 6 at 22:58

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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