|
| 1 | +# Security Key configuration Guide |
| 2 | + |
| 3 | +This document aims to cover the setup and configuration of security keys on GhostBSD. Security keys like YubiKey provide multiple authentication methods and security features that can be used for web authentication, system login, SSH access, and more. |
| 4 | + |
| 5 | +```{contents} Table of Contents |
| 6 | +:depth: 3 |
| 7 | +:local: |
| 8 | +``` |
| 9 | + |
| 10 | +## FIDO2/WebAuthn Security Key Setup |
| 11 | + |
| 12 | +This section will help you set up FIDO2/WebAuthn security keys (like YubiKeys) on GhostBSD. Security keys provide strong two-factor authentication for websites and services that support WebAuthn. |
| 13 | + |
| 14 | +### What You'll Need |
| 15 | + |
| 16 | +- A FIDO2/WebAuthn compatible security key (YubiKey, etc.) |
| 17 | +- Administrator (root) access on your GhostBSD system |
| 18 | +- A web browser (Firefox or Chromium) |
| 19 | + |
| 20 | +### Step 1: Install Required Packages |
| 21 | + |
| 22 | +Open a terminal and install the necessary packages: |
| 23 | + |
| 24 | +```bash |
| 25 | +sudo pkg install libu2f-host libfido2 u2f-devd |
| 26 | +``` |
| 27 | + |
| 28 | +These packages provide: |
| 29 | +- `libu2f-host`: Library for communicating with U2F/FIDO devices |
| 30 | +- `libfido2`: Modern FIDO2/WebAuthn library and tools |
| 31 | +- `u2f-devd`: Device management for security keys |
| 32 | + |
| 33 | +### Step 2: Configure USB HID Support |
| 34 | + |
| 35 | +#### Load USB HID Module |
| 36 | + |
| 37 | +Add the USB HID module to your system's kernel module list: |
| 38 | + |
| 39 | +```bash |
| 40 | +sudo sysrc kld_list+="usbhid" |
| 41 | +``` |
| 42 | + |
| 43 | +This command safely adds `usbhid` to the existing `kld_list` without overwriting other modules. |
| 44 | + |
| 45 | +#### Disable Legacy USB HID |
| 46 | + |
| 47 | +Edit the boot loader configuration: |
| 48 | + |
| 49 | +```bash |
| 50 | +sudo ee /boot/loader.conf |
| 51 | +``` |
| 52 | + |
| 53 | +Add this line: |
| 54 | + |
| 55 | +``` |
| 56 | +hw.usb.usbhid.enable="0" |
| 57 | +``` |
| 58 | + |
| 59 | +This disables the legacy USB HID system in favor of the newer one. |
| 60 | + |
| 61 | +### Step 3: Set Up User Permissions |
| 62 | + |
| 63 | +Add your user account to the `u2f` group: |
| 64 | + |
| 65 | +```bash |
| 66 | +sudo pw group mod u2f -m yourusername |
| 67 | +``` |
| 68 | + |
| 69 | +Replace `yourusername` with your actual username. |
| 70 | + |
| 71 | +**Important:** You must reboot after making these changes for them to take effect. |
| 72 | + |
| 73 | +### Step 4: Reboot Your System |
| 74 | + |
| 75 | +```bash |
| 76 | +sudo reboot |
| 77 | +``` |
| 78 | + |
| 79 | +### Step 5: Test Your Security Key |
| 80 | + |
| 81 | +After rebooting, plug in your security key and test it: |
| 82 | + |
| 83 | +#### Find Your Security Key |
| 84 | + |
| 85 | +```bash |
| 86 | +fido2-token -L |
| 87 | +``` |
| 88 | + |
| 89 | +You should see output like: |
| 90 | +``` |
| 91 | +/dev/uhid3: vendor=0x1050, product=0x0407 (Yubico YubiKey OTP+FIDO+CCID) |
| 92 | +``` |
| 93 | + |
| 94 | +#### Check Device Information |
| 95 | + |
| 96 | +```bash |
| 97 | +fido2-token -I /dev/uhid3 |
| 98 | +``` |
| 99 | + |
| 100 | +Replace `/dev/uhid3` with whatever device path was shown in the previous command. |
| 101 | + |
| 102 | +### Step 6: Configure Your Browser |
| 103 | + |
| 104 | +#### Firefox Configuration |
| 105 | + |
| 106 | +1. Open Firefox |
| 107 | +2. Type `about:config` in the address bar and press Enter |
| 108 | +3. Click "Accept the Risk and Continue" |
| 109 | +4. Search for each setting and change the values: |
| 110 | + |
| 111 | +| Setting | Value | |
| 112 | +|---------|-------| |
| 113 | +| `security.webauth.u2f` | `true` | |
| 114 | +| `security.webauth.webauthn` | `true` | |
| 115 | +| `security.webauth.webauthn_enable_softtoken` | `true` | |
| 116 | +| `security.webauth.webauthn_enable_usbtoken` | `true` | |
| 117 | + |
| 118 | +5. Restart Firefox |
| 119 | + |
| 120 | +#### Chromium Configuration |
| 121 | + |
| 122 | +Chromium usually works with security keys without additional configuration on GhostBSD. |
| 123 | + |
| 124 | +### Step 7: Test WebAuthn |
| 125 | + |
| 126 | +1. Go to [WebAuthn.io](https://webauthn.io) in your browser |
| 127 | +2. Click "Register" to test registration |
| 128 | +3. Enter your security key PIN when prompted |
| 129 | +4. Touch your security key when the browser requests it |
| 130 | +5. Try "Authenticate" to test login |
| 131 | + |
| 132 | +### Troubleshooting |
| 133 | + |
| 134 | +#### Security Key Not Detected |
| 135 | + |
| 136 | +If `fido2-token -L` doesn't show your key: |
| 137 | + |
| 138 | +1. Try unplugging and reinserting the security key. |
| 139 | + |
| 140 | +2. Check if you're in the correct groups: |
| 141 | + ```bash |
| 142 | + groups |
| 143 | + ``` |
| 144 | + You should see `u2f` and `operator` in the output. |
| 145 | + |
| 146 | +3. Check device permissions: |
| 147 | + ```bash |
| 148 | + ls -la /dev/uhid* |
| 149 | + ``` |
| 150 | + Look for a device with group `u2f` or different permissions. |
| 151 | + |
| 152 | +#### PIN Locked Error |
| 153 | + |
| 154 | +If you see "security key is locked" or "wrong pin entered too many times": |
| 155 | + |
| 156 | +1. Check PIN status: |
| 157 | + ```bash |
| 158 | + fido2-token -I /dev/uhid3 |
| 159 | + ``` |
| 160 | + Look for `pin retries: 0` in the output. |
| 161 | + |
| 162 | +2. If PIN retries is 0, you need to reset the FIDO2 application: |
| 163 | + ```bash |
| 164 | + fido2-token -R /dev/uhid3 |
| 165 | + ``` |
| 166 | + **Warning:** This deletes all FIDO2 credentials on the key! |
| 167 | + |
| 168 | +3. When the command runs, immediately touch and hold your security key for 3-5 seconds to confirm the reset. |
| 169 | + |
| 170 | +4. Set a new PIN: |
| 171 | + ```bash |
| 172 | + fido2-token -S /dev/uhid3 |
| 173 | + ``` |
| 174 | + Enter your new PIN twice when prompted. |
| 175 | + |
| 176 | +#### Browser Issues |
| 177 | + |
| 178 | +**Firefox doesn't work but Chromium does:** |
| 179 | +- Double-check the `about:config` settings |
| 180 | +- Try restarting Firefox completely |
| 181 | +- Clear Firefox cache and cookies for the website |
| 182 | +- Try in a private/incognito window |
| 183 | + |
| 184 | +**Neither browser works:** |
| 185 | +- Verify your user is in the `u2f` group: `groups` |
| 186 | +- Try with a different USB port |
| 187 | + |
| 188 | +### Setting Up a PIN (Recommended) |
| 189 | + |
| 190 | +For security, set up a PIN on your security key: |
| 191 | + |
| 192 | +```bash |
| 193 | +fido2-token -S /dev/uhid3 |
| 194 | +``` |
| 195 | + |
| 196 | +Choose a PIN that's at least 4 characters long. You'll need to enter this PIN when using the key for authentication. |
| 197 | + |
| 198 | +### What's Next? |
| 199 | + |
| 200 | +With your security key working, you can now: |
| 201 | + |
| 202 | +- Enable two-factor authentication on websites that support WebAuthn/FIDO2 |
| 203 | +- Use SSH authentication with FIDO2 keys |
| 204 | +- Set up system login with security keys (advanced) |
| 205 | + |
| 206 | +### Common Commands Reference |
| 207 | + |
| 208 | +| Command | Purpose | |
| 209 | +|---------|---------| |
| 210 | +| `fido2-token -L` | List available FIDO2 devices | |
| 211 | +| `fido2-token -I /dev/uhidX` | Show device information | |
| 212 | +| `fido2-token -S /dev/uhidX` | Set initial PIN | |
| 213 | +| `fido2-token -C /dev/uhidX` | Change existing PIN | |
| 214 | +| `fido2-token -R /dev/uhidX` | Reset FIDO2 application (deletes credentials) | |
| 215 | +| `fido2-cred -L /dev/uhidX` | List stored credentials | |
| 216 | + |
| 217 | +Remember to replace `/dev/uhidX` with your actual device path (usually `/dev/uhid3` for security keys). |
| 218 | + |
| 219 | +### Security Notes |
| 220 | + |
| 221 | +- Always set a PIN on your security key for additional security |
| 222 | +- Keep backup authentication methods enabled on important accounts |
| 223 | +- The reset command (`fido2-token -R`) permanently deletes all FIDO2 credentials |
| 224 | +- Other functions on multi-purpose keys (like YubiKey OTP) are not affected by FIDO2 reset |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +**Need more help?** Visit the [GhostBSD Forums](https://forums.ghostbsd.org) for community support. |
0 commit comments