TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The default OpenSSH key encryption is worse than plaintext

545 pointsby rargulatialmost 7 years ago

30 comments

tptacekalmost 7 years ago
Spoiler: the default SSH RSA key format uses straight MD5 to derive the AES key used to encrypt your RSA private key, which means it&#x27;s lightning fast to crack (it&#x27;s &quot;salted&quot;, if you want to use that term, with a random IV).<p>The argument LVH makes here (&quot;worse than plaintext&quot;) is that because you have to type that password regularly, it&#x27;s apt to be one of those important passwords you keep in your brain&#x27;s resident set and derive variants of for different applications. And SSH is basically doing something close to storing it in plaintext. His argument is that the password is probably <i>more important</i> than what it protects. Maybe that&#x27;s not the case for you.<p>I just think it&#x27;s batshit that OpenSSH&#x27;s default is so bad. At the very least: you might as well just not use passwords if you&#x27;re going to accept that default. If you use curve keys, you get a better (bcrypt) format.<p><i>While I have you here...</i><p>Before you contemplate any elaborate new plan to improve the protection of your SSH keys, consider that long-lived SSH credentials are an anti-pattern. If you set up an SSH CA, you can issue time-limited short-term credentials that won&#x27;t sit on your filesystems and backups for all time waiting to leak access to your servers.
评论 #17683102 未加载
评论 #17683617 未加载
评论 #17683864 未加载
评论 #17685560 未加载
评论 #17683261 未加载
评论 #17683012 未加载
评论 #17686362 未加载
评论 #17683061 未加载
评论 #17683410 未加载
评论 #17687322 未加载
评论 #17686032 未加载
评论 #17684211 未加载
评论 #17695865 未加载
评论 #17685275 未加载
评论 #17683913 未加载
jakobdaboalmost 7 years ago
A rogue npm package is my nightmare scenario, those packages are like the only (or I wish..) untrusted code my OS is running.<p>That&#x27;s why I came up with a small script&#x2F;service waiting for an &quot;inotify&quot; event on a honey-pot SSH key (and some other files like ~&#x2F;passwords.doc) which will immediately shutdown the computer on any kind of access of those files.<p><pre><code> #!&#x2F;bin&#x2F;sh inotifywait -e open --fromfile ~&#x2F;.config&#x2F;killer&#x2F;killer.cfg --outfile ~&#x2F;.config&#x2F;killer&#x2F;killer.log if [ $? -eq 0 ]; then poweroff fi</code></pre>
评论 #17683266 未加载
评论 #17683624 未加载
评论 #17683609 未加载
评论 #17683596 未加载
评论 #17684108 未加载
quotemstralmost 7 years ago
Okay. Sure. We should move behind the kindergarten stage of KDF selection. Still, look at the threat model. We&#x27;re talking about the encryption of the private key at rest. In ~&#x2F;.ssh, 0700. If an attacker can even <i>read</i> your private key file, you&#x27;ve probably already lost, encryption or not. That attacker can probably change your .profile to include a keylogger. You lose.<p>I mean, sure. Change the KDF default to something modern. But the threat we&#x27;re discussing is marginal, and it&#x27;s not as if the security of the SSH <i>network protocol</i>, which is paramount, is under threat.<p>If you care about this class of attack, you probably care about it enough to use an SSH CA anyway.
评论 #17685279 未加载
codesectionsalmost 7 years ago
This argument seems to hinge on the following statement that I don&#x27;t understand:<p>&gt; an SSH key password is unlikely to be managed by a password manager: instead it’s something you remember.<p>Why is that the case? I&#x27;ve always been just as likely to use a password manager for my SSH key password—after all, I&#x27;m usually prompted for my SSH key password from my terminal, which accepts pasted passwords just fine.<p>Am I missing something?
评论 #17683970 未加载
simiasalmost 7 years ago
&gt;You might ask yourself how OpenSSH ended up with this. The sad answer is the OpenSSL command line tool had it as a default, and now we’re stuck with it.<p>Given that (as far as I know) the decryption is handled only on the client side, why does an old default matter? Does it break any kind of compatibility to change that? Why only use the better algorithm for EC keys?<p>And even if it did break compatibility it&#x27;s not like it usually stops the OpenSSH folks, old ciphers and hash functions are deprecated regularly (I have to whitelist a bunch of ciphers at work to connect to legacy systems running an old dropbear).
评论 #17684008 未加载
tcmbalmost 7 years ago
I&#x27;m assuming that practically everybody who is a developer on ssh-keygen knows about this. This is not a bug, right?<p>It&#x27;s basically bad usability, where the default is unsafe, and in order to make it safe, you have to know what you&#x27;re doing. Or is it like the author writes in &#x27;TFA&#x27; that &quot;we&#x27;re stuck with it&quot;, because it used to be a default in OpenSSL?<p>Some people will say, &quot;if you&#x27;re using ssh-keygen we can expect that you know what you&#x27;re doing&quot;. But this is a wrong assumption that gets people into trouble. I&#x27;d even say a minority of people who invoke ssh-keygen really know what&#x27;s going on in detail and what providing a flag like &quot;-t ed25519&quot; actually does. I certainly don&#x27;t, and I&#x27;ve had to generate quite a few ssh keys so far.
评论 #17683235 未加载
评论 #17687683 未加载
nebulous1almost 7 years ago
This is a decent article with a click-batey title.<p>The argument that it&#x27;s <i>worse</i> than paintext hinges on you both using a weak password and using the same password for something else. If you don&#x27;t do either of those things then it&#x27;s much better than plaintext, although technically if you use the same strong password for something else then you may have weakened the password by using it for old-format ssh ... but it still has to be brute forced.
评论 #17684281 未加载
评论 #17685478 未加载
jwralmost 7 years ago
I&#x27;d suggest following the excellent guide at <a href="https:&#x2F;&#x2F;github.com&#x2F;drduh&#x2F;YubiKey-Guide" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;drduh&#x2F;YubiKey-Guide</a> and using one of your GPG subkeys (kept on a hardware device like a YubiKey) for SSH authentication.
lvhalmost 7 years ago
I wrote this; happy to answer questions.
评论 #17683575 未加载
评论 #17683166 未加载
评论 #17685211 未加载
评论 #17684254 未加载
评论 #17683775 未加载
AceJohnny2almost 7 years ago
How about using macOS&#x27;s Keychain to store keys?<p>On recent versions, need this in your ~&#x2F;.ssh&#x2F;config:<p><pre><code> # for Keychain (acting as agent) to load the ssh keyfile AddKeysToAgent yes # For ssh to then use Keychain as an agent UseKeychain yes</code></pre>
评论 #17684253 未加载
评论 #17684339 未加载
ejholmesalmost 7 years ago
If you have a recent MacBook, use <a href="https:&#x2F;&#x2F;github.com&#x2F;ntrippar&#x2F;sekey" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ntrippar&#x2F;sekey</a> for SSH keys. Private key is stored in the built-in HSM (Secure Enclave) and access is controlled by biometrics (TouchID). You can do the same with a Yubikey, but it’s not quite as good because a) you can lose your Yubikey easily and b) there’s no biometrics.<p>Private keys stored on filesystems is an antipattern.
评论 #17695384 未加载
amenghraalmost 7 years ago
My ssh key is stored in a yubikey. Haven’t had to type a password for ssh purpose in a long time!
评论 #17683263 未加载
knorkeralmost 7 years ago
If you have really old clients you may apparently be able to do this instead:<p><a href="https:&#x2F;&#x2F;martin.kleppmann.com&#x2F;2013&#x2F;05&#x2F;24&#x2F;improving-security-of-ssh-private-keys.html" rel="nofollow">https:&#x2F;&#x2F;martin.kleppmann.com&#x2F;2013&#x2F;05&#x2F;24&#x2F;improving-security-o...</a>
bogomipzalmost 7 years ago
&gt;&quot;You might ask yourself how OpenSSH ended up with this. The sad answer is the OpenSSL command line tool had it as a default, and now we’re stuck with it.&quot;<p>Could someone elaborate on this? Is this saying that the ssh-keygen utility shells out to the openssl-command line tool which at one point defaulted to md5 for encryption? If this is the case why would be stuck with it?
评论 #17684640 未加载
spiznnxalmost 7 years ago
It&#x27;s best to assume all passwords need to have sufficient entropy to withstand a brute-force attack on some super fast hash until proven otherwise.<p>I didn&#x27;t change my macOS password to 8-characters (to save myself 20 seconds a day) until I thoroughly researched what key-stretching was being used under the hood.
bogomipzalmost 7 years ago
The author states:<p>&gt;&quot;Finally, most startups should consider not having long-held SSH keys, instead using temporary credentials issued by an SSH CA, ideally gated on SSO.&quot;<p>Can someone explain what &quot;gating&quot; SSH CA issued key with SSO means? How would SSO &quot;gate&quot; the keys?
评论 #17684645 未加载
valenciarosealmost 7 years ago
Use SSH keys generated and stored on some sort of PKCS11&#x2F;PIV hardware device. It’s relatively easy to do now. Don’t trust a general purpose computer to keep your keys secure.<p>Better yet, use U2F where you have control of how you are authenticated.
technionalmost 7 years ago
<p><pre><code> It’s tricky to find out what this DEK-Info stuff means </code></pre> This is really where the modern crypto protocols and libraries are doing well imo. Even if something that opaque is implemented perfectly, it presents a risk.
nebulous1almost 7 years ago
tl;dr to move to the newer more secure format use<p><pre><code> ssh-keygen -o -p -f file_name </code></pre> such as:<p><pre><code> ssh-keygen -o -p -f ~&#x2F;.ssh&#x2F;id_rsa </code></pre> not necessary for ed25519 as it can only be stored in the new format.
lwfalmost 7 years ago
Filed <a href="https:&#x2F;&#x2F;bugs.debian.org&#x2F;cgi-bin&#x2F;bugreport.cgi?bug=905407" rel="nofollow">https:&#x2F;&#x2F;bugs.debian.org&#x2F;cgi-bin&#x2F;bugreport.cgi?bug=905407</a> to change the Debian default.
otterleyalmost 7 years ago
Is anyone aware of a successful infiltration of a system that occurred by stealing an encrypted SSH key with a reasonably good password and successfully decrypting it?
评论 #17688125 未加载
digitalnalogikaalmost 7 years ago
What are you thoughts on using Krypton? <a href="https:&#x2F;&#x2F;krypt.co" rel="nofollow">https:&#x2F;&#x2F;krypt.co</a>
w8rbtalmost 7 years ago
All my ssh key passwords are generated from password managers. They are random and strong.
gigatexalalmost 7 years ago
What if you generate the public and private keys without a password but keep it blank?
adultSwimalmost 7 years ago
I&#x27;m finally vindicated for not using a password on my key :P
drb91almost 7 years ago
Does this affect non-RSA key types too? I use ecsda25519.
评论 #17684522 未加载
nerdponxalmost 7 years ago
So is that what happened? Somebody got a hold of one of the developers&#x27; private SSH keys, and cracked the encryption?
exabrialalmost 7 years ago
Seems like gpg auth would be a much better choice the ssh keys
jwildeboeralmost 7 years ago
Nice deflection of the real madness here that a compromised npm package gets to read stuff in your user directory.
评论 #17683103 未加载
评论 #17683062 未加载
评论 #17683036 未加载
评论 #17683423 未加载
mrrandomguy11almost 7 years ago
Use key AND interactive password. This way attacker will have limited rate of password guessing and you will now from logs that your key is compromised. Your key will be used only for first step of authorization. You can slap additional password for that key but it is not even needed. Additionally from what I remember Ed25519 keys are stored by default in the new format.
评论 #17684787 未加载