OpenSSL Hacks
Here's something that GnuPG can't do. OpenSSL has a built-in command for creating encrypted Linux passwords exactly like those made by /bin/passwd.
Skip this paragraph to avoid pedantic cryptography. Although commonly called encrypted, Linux passwords are actually hashed using either MD5 or the old UNIX password hash (based on the DES encryption algorithm). This allows Linux not to know your password even though it knows when you provide the correct password. When you set your password, Linux hashes your password and stores it in /etc/shadow. When you log in, Linux takes the password you provide and hashes it again, and then compares that hash to what's stored in /etc/shadow for your account. If they match, you provided the correct password and can log in. If they don't match, you don't know your password, and because only the hash was stored, the computer still doesn't know your password either.
Here's why making your own password hash is useful. Let's say you need a new password on another computer. Perhaps it's a new account or you forgot the old password and asked the system administrator to reset it for you. If you can talk to the sysadmin in person, this works well, but what if the sysadmin is somewhere else? Perhaps you've never even met your sysadmin. How do you communicate your new password? E-mail is not secure at all, and telephones are scarcely better. Postal mail takes days (and has other security problems). Fax machines, text messaging and most pagers aren't secure either.
It gets worse. Maybe you don't even trust that sysadmin. Sure, the sysadmin usually has root, but someone else knowing your password bypasses even root accountability. Maybe you want to use the same password on other computers, and you don't trust those sysadmins either.
So, do this instead:
$ openssl passwd -1 Password: Verifying - Password: $1$zmUy5lry$aG45DkcaJwM/GNlpBLTDy0
Enter your new password twice; it won't echo. If you have multiple accounts, run the above example multiple times. The output is the cryptographic hash of your password. The hash is randomly salted so that every time it's run, the output will be different, even if the password is the same.
In my example, the password hash is:
$1$zmUy5lry$aG45DkcaJwM/GNlpBLTDy0
Your password hash probably will be completely different, except for the initial $1$.
This password hash can now be e-mailed, faxed, text messaged or even spoken over the phone to a sysadmin to set as your password hash.
After the sysadmin receives your password hash, it can be entered into /etc/shadow manually or with chpasswd. The latter requires a temporary new file, call it newpassword, with your loginid and password hash like this:
LoginidHere:$1$ywrU2ttf$yjm9OXTIBnoKJLQK2Fw5c/
The file can contain multiple lines for other accounts too.
Then, the sysadmin runs this as root:
chpasswd --encrypted < newpassword
Now, the new password is set. It's a good idea to change your password once you log in, unless you use a really strong passphrase. This is because the password hash, once exposed, is subject to off-line brute-force attacks, unless the password is really long.
This method of resetting passwords can be quite secure. For example, using this technique, someone could take the password hash published above, create an account, then tell the person the loginid and hostname and that the password hash above was used. Only the person who originally created the password hash could know the password, even though the password hash was published in a magazine.
By the way, the password for that hash is 28 completely random base64 characters long, so it should be extremely difficult to crack. But please, don't create any accounts with that hash because the password is also published, it's:
HXzNnCTo8k44k8v7iz4ZkR/QWkM2
That password and hash were created like this:
$ openssl rand 21 -base64 HXzNnCTo8k44k8v7iz4ZkR/QWkM2 $ openssl passwd -1 HXzNnCTo8k44k8v7iz4ZkR/QWkM2
These examples use the MD5 password hashes now common on Linux systems. If you need to use the old UNIX password hash, simply leave off the -1. For example:
$ openssl passwd Password: Verifying - Password: xcx7DofWC0LpQ
The password for this last password hash example is: TheLinux.
The many algorithms that OpenSSL supports makes it well suited for cryptographic benchmarking. This is useful for comparing the relative performance of different cryptographic algorithms and different hardware architectures using a consistent code base. And, it has a built-in benchmarking command.
The openssl speed command, by default, runs through every single algorithm in every single supported mode and option, with several different sizes of data. The different sizes are important because of algorithm start-up overhead.
A complete speed run takes about six minutes, regardless of hardware performance, and produces 124 lines of performance data with 29 lines of summary.
However, note that cryptographic algorithm performance is extremely dependent on the specific implementation. For higher performance, OpenSSL has x86 assembly code for several algorithms. Other architectures, such as ia64, SPARC and x86-64, have much less assembly code, and most others have none. The assembly code is located in these OpenSSL source code directories: crypto/*/asm. Excerpts of the speed report for three different systems are shown in Tables 2 and 3.
Table 2. Hash and Block Cipher Performance (The numbers are in 1,000s of bytes per second using 1,024-byte blocks.)
| AMD K6-2 300MHz, Linux 2.6.12, OpenSSL 0.9.7g | AMD Athlon 1.333GHz, Linux 2.4.27, OpenSSL 0.9.7d | PowerMac G5 1.6GHz, Darwin Kernel Version 8.0.0, OpenSSL 0.9.7b | |
|---|---|---|---|
| md5 | 26,733.93k | 169,207.13k | 76,921.71k |
| sha1 | 12,665.41k | 113,973.25k | 76,187.82k |
| blowfish cbc | 9,663.40k | 56,940.54k | 44,433.14k |
| aes-128 cbc | 5,134.78k | 31,355.90k | 54,987.78k |
Table 3. Public Key Crypto Performance
| sign/s | verify/s | ||
|---|---|---|---|
| rsa 1024 bits | 30.8 | 563.1 | AMD K6-2 300MHz, Linux 2.6.12, OpenSSL 0.9.7g |
| dsa 1024 bits | 61.6 | 50.7 | AMD K6-2 300MHz, Linux 2.6.12, OpenSSL 0.9.7g |
| rsa 1024 bits | 239.9 | 4,514.6 | AMD Athlon 1.333 GHz, Linux 2.4.27, OpenSSL 0.9.7d |
| dsa 1024 bits | 498.2 | 410.6 | AMD Athlon 1.333 GHz, Linux 2.4.27, OpenSSL 0.9.7d |
| rsa 1024 bits | 148.8 | 2,739.1 | PowerMac G5 1.6 GHz, Darwin Kernel Version 8.0.0, OpenSSL 0.9.7b |
| dsa 1024 bits | 289.5 | 234.6 | PowerMac G5 1.6 GHz, Darwin Kernel Version 8.0.0, OpenSSL 0.9.7b |
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Speed Up Your Web Site with Varnish | Jun 19, 2013 |
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Android's Limits
- Web & UI Developer (JavaScript & j Query)
- Reply to comment | Linux Journal
1 min 53 sec ago - Yeah, user namespaces are
1 hour 18 min ago - Cari Uang
4 hours 49 min ago - user namespaces
7 hours 43 min ago - yea
8 hours 8 min ago - One advantage with VMs
10 hours 37 min ago - about info
11 hours 10 min ago - info
11 hours 11 min ago - info
11 hours 12 min ago - info
11 hours 14 min ago
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
In relation to the password
In relation to the password hash, surely the server needs to know the salt too? When I run the example I don't get the salt returned, so how can the hash be used?? Can the salt be derived from the hash somehow, and if so, doesn't knowledge of the salt make the hash much, much weaker?
I'm sure I've missed something obvious!
As far as I know, the salt
As far as I know, the salt is stored between two dollar signs. So it's part of the hash. At least for the MD5 (openssl passwd -1).
MD5 passwd hash
I need a cc or gcc source file that I can compile on an HP running HPUX 11. I want to compile it into an existing process that currently generates and hashes 8 digit passwords using DES i.e., the old crypt(). I nust now increase that password from 8 positions to 15 for security purposes. I'd guess that a perl script would do also as long as it had the proper hooks to the MD5 hash.
I will really appreciate any help on this item.
RE:
Great Article Anthony!
Very interesting and informational.
Can you expand a little on where you say:
"...run the above example multiple times. The output is the cryptographic hash of your password. The hash is randomly salted so that every time it's run, the output will be different, even if the password is the same."
Why will the output be different?
Thanks!
-John
salt
Basically, salt is a random string appended to your password. So instead of hash(password), we do hash(password | salt). The server keeps both salt and hash value. The purpose of salt is to prevent pre-calculated table attack.
Ref: http://en.wikipedia.org/wiki/Salt_%28cryptography%29
Page is rendered too wide
The lines on this page are too wide, I have to scroll horizontally to read each line, hence I haven't read the article.
The problem seems to be Table 2, and specifically the header lines, but Table 3 may also be wide on some screens.
I'm sure someone can find a number of creative ways to solve the problem.
Randy Kramer
Page is rendered too wide
In most browsers, those capable of handling cascading style sheets (CSS) that table displays with a horizontal scroll bar at the bottom and does not extend the page width.
What browser are you using and what version?
Webmaster
Linux Journal
I forgot to ask
Have you changed the settings in your browser so you use a default or customized style sheet for it? This is common with Opera.
Webmaster
Linux Journal
"I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone."
-- Bjarne Stroustrup
Width problem
The width problem on this page as commented by others is still there. Using Konqueror 3.5.4 on Kubuntu with stylesheet set as default. Browser as-is passes the acid style test 100%. The problem is with your site.
Sorry.
Allan Morris.
Width problem
There were two problems here. Though I made the page quit showing so wide, the problems still exist.
Problem #1 Konqueror will not obey the CSS rule (overflow: auto;) for a table which would make a horizontal scroll bar appear only underneath the over sized table and the screen would not display wide. All other browsers I tested do this.
Problem #2 Konqueror obeyed a CSS rule for table headers (th{white-space: nowrap;}) that none of the other browsers paid any attention to. I killed the white-space rule and the page no longer over extends your screen (or at least not as much, there is still a point where the table headers will not continue to wrap). If the other browsers had obeyed this rule I would have found this problem much earlier.
Webmaster
"I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone."
-- Bjarne Stroustrup