TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to Store an SSH Key on a Yubikey

298 点作者 kadenwolff将近 3 年前

25 条评论

nextlevelwizard将近 3 年前
I know Yubikeys are pretty old hat by now, but I still feel weirded out by relying something like this into a USB stick. I just know I would lose the key at some point locking me out from everything. Of course the solution is to have two keys, but don&#x27;t really know where I would feel comfortable storing the extra key (also how often do you check that it still works?)<p>I&#x27;m probably just over thinking this and overly paranoid.
评论 #31556825 未加载
评论 #31556677 未加载
评论 #31556417 未加载
评论 #31556433 未加载
评论 #31557251 未加载
评论 #31560904 未加载
评论 #31557092 未加载
评论 #31556681 未加载
评论 #31557451 未加载
评论 #31557367 未加载
评论 #31560790 未加载
评论 #31558813 未加载
评论 #31557306 未加载
评论 #31559367 未加载
评论 #31558056 未加载
评论 #31556532 未加载
评论 #31560003 未加载
评论 #31556753 未加载
评论 #31557503 未加载
评论 #31558704 未加载
评论 #31562778 未加载
评论 #31558427 未加载
评论 #31559986 未加载
评论 #31558170 未加载
评论 #31557724 未加载
评论 #31557014 未加载
评论 #31558723 未加载
评论 #31557567 未加载
评论 #31557020 未加载
vladvasiliu将近 3 年前
&gt; As of OpenSSH 8.2 (Feburary 14, 2020) you are able to store an SSH private key on a yubikey! Here&#x27;s how to do it.<p>Many systems still don&#x27;t have OpenSSH 8.2 (Windows 11, older debian stable, etc). For those, another solution is to use the PGP applet of the YubiKey, which exposes a regular RSA key.<p>This guide has worked well for me: <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><p>You can jump to the SSH sections if that&#x27;s all you&#x27;re after.<p>There&#x27;s a missing piece for Windows, since the agent coming with WinGPG won&#x27;t be reachable by SSH. Some guy on GitHub put out a workaround, but I can&#x27;t find it right now.<p>--<p>edit: The workaround for Windows is this one: <a href="https:&#x2F;&#x2F;github.com&#x2F;rupor-github&#x2F;win-gpg-agent" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rupor-github&#x2F;win-gpg-agent</a>
评论 #31557276 未加载
评论 #31556605 未加载
评论 #31557467 未加载
评论 #31557462 未加载
seodisparate将近 3 年前
You can use a GPG key stored on a YubiKey with openssh, but with some caveats:<p>1. gpg-agent must act as your ssh-agent (which means ssh-agent should be disabled and replaced by gpg-agent).<p>2. If using `pinentry-curses` (YubiKey usually permits access to the contained GPG key via the use of a pin), you must have `export GPG_TTY=$(tty)` (or your shell&#x27;s equivalent of setting the GPG_TTY environment value to the output of `tty`).<p>3. You can fetch the public key of your GPG key with `ssh-add -L` (gpg-agent must be acting as your ssh-agent, and the YubiKey with the GPG key has to be plugged in).<p>4. You must have the line `enable-ssh-support` in your `$GNUPGHOME&#x2F;gpg-agent.conf`.<p>I used a guide[1] to set up a GPG key on to a YubiKey, and for those who don&#x27;t want to use GPG, the guide also has a section[2] about just using an SSH key as well.<p>[1]: <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><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;drduh&#x2F;YubiKey-Guide#ssh" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;drduh&#x2F;YubiKey-Guide#ssh</a>
评论 #31559680 未加载
enasterosophes将近 3 年前
Something else that is quite nice is that you can switch to certificate auth and use your yubikey to protect an ed25519-sk certificate authority.
评论 #31556425 未加载
评论 #31557067 未加载
评论 #31556387 未加载
WhyNotHugo将近 3 年前
Yubikeys (and similar hardware tokens) are a blessing for authentication.<p>I use them for SSH, but also for 2FA on the web, `sudo` and a few other items. Wrote about it recently here:<p><a href="https:&#x2F;&#x2F;hugo.barrera.io&#x2F;journal&#x2F;2022&#x2F;05&#x2F;07&#x2F;how-i-secure-my-setup-with-a-yubikey&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hugo.barrera.io&#x2F;journal&#x2F;2022&#x2F;05&#x2F;07&#x2F;how-i-secure-my-s...</a>
fmajid将近 3 年前
Yubikey Manager is not needed to use ed25519-sk keys. They use only FIDO U2F functionality, so cheaper USB keys ($29 for a Yubico Security Key USB-C NFC vs $55 for the full Yubikey 5C NFC).<p>They are thus not limited to Yubico&#x27;s proprietary functionality controlled by Manager, which has a wider attack surface than I am comfortable with, and are not limited to platforms running the Yubikey Manager software (e.g. on OpenBSD). Since the key has never been outside the USB enclave, there is no way it could have been surreptitiously copied, e.g. if there was a rootkit on the machine where the key was generated before copying to the Yubikey.
jopsen将近 3 年前
Curious, if you delete the stub in ~&#x2F;.ssh&#x2F;id_ed25519_sk, can you then recover the key?<p>Or does the on-the-fly key generation use random bytes stored in the stub?
评论 #31556712 未加载
veganjay将近 3 年前
Thanks for sharing the article. I followed it and it was very simple to set up.<p>In the past, I postponed setting this up after I encountered issues. I tried to run &quot;ykman&quot;, but it seemed to fight with &quot;yubioath-desktop&quot;. It was tricky to debug and I ended up rebooting. I think the reason was that I installed &quot;yubioath-desktop&quot; using snap, which runs &quot;pcscd&quot; as a snap service, and &quot;ykman&quot; wants to start the &quot;pcscd&quot; system service.<p>Either case, for this tutorial, I skipped the part running &#x27;ykman&#x27;. Basically the only commands were:<p><pre><code> ssh-keygen -t ed25519-sk -O resident ssh-add -K</code></pre>
sandreas将近 3 年前
For those who like to know more details about Yubikeys, I found this pretty interesting: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=INi-xKpYjbE" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=INi-xKpYjbE</a>
markstos将近 3 年前
Unless I&#x27;ve missed something, SSH keys stored on Yubikeys are still hampered because you aren&#x27;t allowed to a touch policy of &quot;touch never&quot;.<p>Imagine needing to touch the Yubikey with each &quot;git pull&quot; or using Ansible to operate over SSH on a dozen servers in parallel, and needing to touch the Yubikey once for each server.<p>The feature request I&#x27;m tracking is here: <a href="https:&#x2F;&#x2F;github.com&#x2F;FiloSottile&#x2F;yubikey-agent&#x2F;issues&#x2F;95" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;FiloSottile&#x2F;yubikey-agent&#x2F;issues&#x2F;95</a><p>The proposed feature would allow setting a touch policy for the SSH key.
评论 #31561584 未加载
ChrisMarshallNY将近 3 年前
What I would love, and it has not been supported (I was basically told “Go away, kid. Yer bodderin’ me!”, when I suggested it to AgileBits), is the ability to store the local 1Password vaults onto a separate volume from the main one.<p>I have a small encrypted disk image that I mount, after booting my computer. A YubiKey would be similar. I use this to store my really critical stuff. I don’t back up the mounted disk, but do back up the encrypted image.
评论 #31557100 未加载
a-dub将近 3 年前
but wait a minute... this is just storing the private key material on the yubikey like any storage device and it is loaded and copied right off every time you use it, right?<p>doesn&#x27;t that defeat the point of using a yubikey where the private key itself is never read from the device during authentication?
评论 #31558523 未加载
评论 #31558527 未加载
veganjay将近 3 年前
Is there a way to show which SSH keys are loaded on the Yubikey? (It looks like you can store multiple)<p>Also, how can one remove the SSH keys from the Yubikey?<p>I&#x27;ve tried to find articles and SSH on the Yubikey gets very confusing as there seem to be so many techniques!
评论 #31559841 未加载
veganjay将近 3 年前
Some additional information:<p>- <a href="https:&#x2F;&#x2F;www.yubico.com&#x2F;blog&#x2F;github-now-supports-ssh-security-keys&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.yubico.com&#x2F;blog&#x2F;github-now-supports-ssh-security...</a><p>- <a href="https:&#x2F;&#x2F;developers.yubico.com&#x2F;SSH&#x2F;Securing_SSH_with_FIDO2.html" rel="nofollow">https:&#x2F;&#x2F;developers.yubico.com&#x2F;SSH&#x2F;Securing_SSH_with_FIDO2.ht...</a><p>- <a href="https:&#x2F;&#x2F;developers.yubico.com&#x2F;SSH&#x2F;" rel="nofollow">https:&#x2F;&#x2F;developers.yubico.com&#x2F;SSH&#x2F;</a><p>The second link describes the advantages&#x2F;disadvantages of non-resident vs. resident keys.
xvector将近 3 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;FiloSottile&#x2F;yubikey-agent" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;FiloSottile&#x2F;yubikey-agent</a> has worked really well for me in the past.
评论 #31556721 未加载
archi42将近 3 年前
&gt; This should work on other FIDO keys like Google&#x27;s Titan, but we don&#x27;t have access to one over here and as such haven&#x27;t tested it.<p>For my trusty HyperFIDO Mini (usb id 0x2ccf:0x0880) this doesn&#x27;t work, though it&#x27;s rather old (1st gen) and maybe they refreshed it to support this. ssh-keygen fails with &quot;Key enrollment failed: requested feature not supported&quot;. I wanted to replace it with a USB-C (&amp; maybe NFC) device anyway, so seems like a good opportunity.
评论 #31558315 未加载
nyanpasu64将近 3 年前
I tried ed25519-sk keys last year, but abandoned them when GitLab wouldn&#x27;t recognize their public keys. It seems that as of 3 months ago GitLab has added support (<a href="https:&#x2F;&#x2F;gitlab.com&#x2F;gitlab-org&#x2F;gitlab&#x2F;-&#x2F;issues&#x2F;213259" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;gitlab-org&#x2F;gitlab&#x2F;-&#x2F;issues&#x2F;213259</a>) so I should give them another try.
ndsipa_pomu将近 3 年前
Is it possible to do something similar with an NFC smart ring? I&#x27;d be much less likely to lose a ring than a Yubikey.
tazjin将近 3 年前
The problem with this approach is that the `-sk` keys need to be supported server-side (I&#x27;m not sure if that support goes beyond including them in a list of recognised key types, but it doesn&#x27;t matter).<p>As a result, lots of systems that are not bleeding edge still don&#x27;t accept them, for example Gerrit.
评论 #31558216 未加载
gwbas1c将近 3 年前
&gt; such as the Tongues you received as a kid when you were forced into learning the bible against your will<p>Wait, what? My wife stopped going to Awanas when some leader told her she was going to hell for not learning the Bible verses. Later I learned that her father was pissed off about the whole situation.
评论 #31560918 未加载
评论 #31560559 未加载
jazzythom将近 3 年前
Wait is generation on the host? Nonono you generate a GPG key on the key then export the public key and derive the SSH key. These instructions are wrong the host never should store the key even if airgapped
评论 #31563929 未加载
bschne将近 3 年前
Are there any best practices on using one of the &quot;-sk&quot; key types and authorizing usage with your security key, vs. storing the whole ssh key on the security key?
moontear将近 3 年前
OT: what kind of date format is used in the article? It says „M05 27 2022“ and I have not seen that before. Does M05 mean May-05, so basically saying may-may?
评论 #31556808 未加载
评论 #31556511 未加载
jve将近 3 年前
While we&#x27;re at this - is there anyway for sudo NOT to ask for password when logged in via key authentication?
评论 #31565669 未加载
netfortius将近 3 年前
It&#x27;s actually even cooler to store them on a Ledger device