Network security

How to Lock USB Ports on Windows, Mac and Linux (2026 Guide)

Most of the time you do not need to disable the ports themselves — you need to block USB storage. Here are the Windows, Mac and Linux methods that do it, and when to use each one.

Cysoro Security TeamPublished · 7 min read
STORAGE BLOCKED DENIED NETWORK SECURITY Lock USB ports Block the drive, keep the keyboard.
Quick answer

To lock USB ports on Windows, use Group Policy (Computer Configuration, Administrative Templates, System, Removable Storage Access) and enable All Removable Storage classes: Deny all access, then run gpupdate /force. That blocks USB storage while keyboards, mice and security keys keep working. For a single home PC, the registry USBSTOR method or Device Manager works instead; Mac and Linux need MDM profiles or kernel module rules.

Key takeaways

  • Block USB storage, not the whole port, unless the machine is a kiosk or high-security workstation.
  • Group Policy is the right method for managed Windows PCs; the registry USBSTOR value is the right method for a single Windows Home PC.
  • Always allowlist approved encrypted drives and security keys before you lock everything else, or you will lock yourself out of your own workflow.

A USB port is a front door to your computer. A flash drive found in a car park, a borrowed external disk, or a charging cable with hidden storage can copy data out or bring malware in — in seconds, with no password prompt.

What does locking USB ports actually mean?

Locking USB ports usually means blocking USB storage, not switching the ports off. Flash drives and external disks stop working, while keyboards, mice, headsets and security keys keep working normally.

That distinction matters. Fully disabling a port in Device Manager or BIOS also kills the keyboard, mouse and security key on that port. Most people who search for how to lock USB ports want the storage block, and they should start there.

There are four levels of control, from lightest to strictest. Pick the lightest one that solves your problem, and test it before you roll it out.

LevelWhat it blocksBest forEffort
Block USB storageFlash drives and external disks onlyMost homes and officesLow
Read-only USB storageWriting to drives; reading still worksShared PCs, kiosks that need files inLow
Allowlist specific devicesEverything except approved drivesRegulated teams, finance, healthcareMedium
Disable the port entirelyEvery USB device on that portKiosks, high-security machinesLow, but risky

Why lock USB ports at all?

USB drives are a classic way for data to leave a company and for malware to get in. An employee can copy a customer list to a pocket drive, and a single infected drive can spread ransomware across a network.

CISA's ransomware guidance stresses offline backups and patching, because ransomware variants actively hunt for accessible backups and spread through unpatched systems. A USB lock is one control in that layered approach, not a replacement for backups or updates.

Common reasons to lock USB ports include stopping data theft, stopping malware from found or borrowed drives, meeting a compliance requirement, and protecting shared or public computers. If none of those apply, a storage block on shared machines is still cheap insurance.

Back up firstBefore you change Group Policy, the registry or BIOS settings, make a full backup or a system restore point. A wrong registry edit or a disabled controller can leave a machine unusable until you fix it.

How do I lock USB ports on Windows with Group Policy?

Group Policy is the cleanest method for Windows Pro, Enterprise and Education, and for any domain-joined PC. It blocks every removable storage class and leaves other USB devices alone.

Block USB storage with Group Policy1. Open gpedit.mscWindows + R, type gpedit.msc2. Find the settingRemovable Storage Access3. Enable the blockDeny all access: Enabled4. Apply itgpupdate /forceFull path: Computer Configuration > Administrative Templates > System > Removable Storage AccessSetting: All Removable Storage classes: Deny all accessWant read-only instead? Leave that setting off.Enable Removable Disks: Deny write access — users can open files but cannot copy anything to a drive.
The Group Policy path to block USB storage on Windows. Illustration by Cysoro.
  1. Press Windows + R, type gpedit.msc and press Enter. On a domain, edit a Group Policy Object in Group Policy Management instead.
  2. Go to Computer Configuration > Administrative Templates > System > Removable Storage Access.
  3. Open All Removable Storage classes: Deny all access, select Enabled and click OK.
  4. Run gpupdate /force in Command Prompt, then unplug and reconnect a drive to check it is blocked.

This setting takes precedence over the individual removable storage settings in the same folder. If you want read-only access instead of a full block, leave it off and enable Removable Disks: Deny write access.

To roll it out to many machines, create the policy once on a domain controller with the Group Policy Management Console, link it to the right organizational unit, and let gpupdate apply it.

ManageEngine's GPO guide shows the same path under Computer Configuration, Policies, Administrative Templates, System, Removable Storage Access.

How do I lock USB ports on Windows Home with the registry?

Windows Home has no Group Policy Editor, so use the registry. This method stops the USB mass storage driver from loading, which blocks flash drives and external disks.

  1. Press Windows + R, type regedit and press Enter. You need administrator rights.
  2. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR.
  3. Double-click the Start value and change it from 3 (enabled) to 4 (disabled).
  4. Restart the computer and test with a flash drive.

To undo it, set Start back to 3 and restart. You can also do the same change from an elevated Command Prompt with reg add HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR /v Start /t REG_DWORD /d 4 /f, then restart.

Do not edit other registry keys while you are there. Export the USBSTOR key before you change it, so you can restore it if something goes wrong. This method blocks storage only; it does not stop a USB keyboard or mouse.

How do I disable USB ports completely in Device Manager or BIOS?

Disabling a port completely is for kiosks and high-security machines, not everyday PCs. It stops every device on that port, including the keyboard and mouse.

In Device Manager, press Windows + R, type devmgmt.msc, expand Universal Serial Bus controllers, right-click a USB Root Hub or host controller and choose Disable device. Test immediately: if your keyboard or mouse stops working, you disabled the wrong controller.

In BIOS or UEFI, restart the PC, enter firmware setup, and look for USB configuration or USB port settings. Most business PCs let you disable USB ports entirely, or just disable booting from USB. Disabling USB boot is a sensible middle step: it stops someone booting a live operating system from a drive, without breaking daily use.

Physical port locks are the last resort. Small plastic blockers fit into unused USB-A ports and need a key to remove. They work well on public-facing machines, but they are easy to forget about and annoying when you genuinely need a port.

How do I lock USB ports on Mac and Linux?

Macs and Linux PCs need different tools, because neither has Group Policy. The goal is the same: block storage, allowlist trusted devices, and stop booting from external drives.

Locking USB on a Mac

On a managed Mac, use your MDM to push a profile that restricts removable storage. On a single Mac, turn on FileVault so the disk is encrypted, set a firmware password to stop booting from an external drive, and use System Settings to control which USB accessories can connect when the Mac is locked.

For stricter control, use an endpoint security or DLP tool that can block USB storage per device. Test with the exact drives your team uses, because a blanket block can also stop a legitimate backup drive.

Locking USB on Linux

On Linux, block the USB storage kernel module. Create a file such as /etc/modprobe.d/block-usb-storage.conf containing install usb-storage /bin/false, update the initramfs, and reboot. After that, USB storage devices will not load.

For finer control, use USBGuard. It lets you write rules that allow specific devices by vendor and product ID and block everything else. That is the Linux equivalent of a Windows hardware-ID allowlist, and it is the right choice when some drives must work.

Which method fits your computer?Windows Pro / EnterpriseGroup Policy:Deny all accessBest for fleets anddomain-joined PCsCentral, reversibleWindows HomeRegistry: USBSTORStart value 4Best for one PC athomeSimple, needs restartMac and LinuxMDM profile orUSBGuard / modprobeBest for mixed fleetsand single machinesAllowlist friendly
Pick the USB locking method that matches your operating system and fleet size. Illustration by Cysoro.

How do I allow trusted USB drives and block the rest?

A blanket block breaks legitimate work: encrypted backup drives, approved transfer drives and security keys all use USB. Allowlisting solves that by approving specific devices and blocking everything else.

On managed Windows, use Device Installation Restrictions in Group Policy. Enable Prevent installation of devices that match any of these device IDs, or the allowlist equivalent, and add the hardware IDs of the drives you approve. You can find a device's hardware ID in Device Manager under Properties, Details, Hardware Ids.

Endpoint DLP tools do the same job with a friendlier interface: approve a drive by serial number, require encryption, and log every copy. That logging matters — it turns a silent data leak into an auditable event.

Whatever method you use, test the allowlist with the exact drive, on the exact machine, before you roll it out. A drive that works on one PC can fail on another if the hardware ID differs by revision.

What mistakes should I avoid when locking USB ports?

Most USB-locking problems come from locking too much, too fast, with no way back. Avoid these five mistakes.

  • Disabling the port your keyboard uses. Block storage classes first. Only disable controllers on machines with a spare input method.
  • Locking security keys. A storage block should not affect FIDO2 keys, but a full port disable will. Test your key after every change.
  • Forgetting Windows Home has no Group Policy. Pushing a Group Policy fix to a Home PC wastes an afternoon. Use the registry method there.
  • No exception process. Someone will legitimately need a drive. Give them a named approver and an approved encrypted drive, or they will find a workaround.
  • Thinking the lock is the whole defense. USB locks stop casual copying and drive-borne malware. They do not stop cloud uploads, email exfiltration or phishing. Pair them with the controls in our small business cybersecurity checklist.

Also remember that a locked port does not protect data already on a lost drive. Encrypt portable drives with BitLocker or your platform's equivalent, so a lost drive is a lost drive, not a breach.

USB locks are one part of device security. Our guide to how to know if your phone is hacked covers the other end of the same problem: untrusted devices connecting to your accounts.

The bottom line

For most people, the right answer is to block USB storage, not the ports. Group Policy does it cleanly on managed Windows, the USBSTOR registry value does it on Windows Home, and MDM profiles or USBGuard do it on Mac and Linux.

Start with one test machine, confirm your keyboard, mouse and security key still work, allowlist the drives you actually need, and then roll the policy out. You can check the rest of your baseline — headers, certificates and email authentication — with the free security headers checker.

Frequently asked questions

How do I lock USB ports on Windows 10 or 11?

Use Group Policy if you have Windows Pro, Enterprise or Education: open gpedit.msc, go to Computer Configuration, Administrative Templates, System, Removable Storage Access, and enable All Removable Storage classes: Deny all access. Then run gpupdate /force. On Windows Home, use the registry USBSTOR method instead, because Home has no Group Policy Editor.

Does blocking USB storage stop my keyboard and mouse?

No, if you block storage classes only. Group Policy removable-storage settings and the USBSTOR registry value stop flash drives and external disks, while keyboards, mice, headsets and security keys keep working. Disabling a USB controller in Device Manager or BIOS is different: it can stop every device on that port.

How do I lock USB ports on a Mac?

Macs have no built-in Group Policy equivalent. Use an MDM profile to restrict removable storage, or a third-party endpoint tool. On a single Mac, you can also use System Settings to control which accessories can connect, and FileVault plus a firmware password to stop booting from an external drive.

How do I lock USB ports on Linux?

Block the USB storage kernel module by adding a file such as /etc/modprobe.d/block-usb-storage.conf containing install usb-storage /bin/false, then update the initramfs and reboot. For finer control, use USBGuard to allowlist specific devices by vendor and product ID and block everything else.

Can I allow one trusted USB drive and block all others?

Yes. On managed Windows, use Device Installation Restrictions in Group Policy to allowlist by hardware ID, or use an endpoint DLP tool that approves specific encrypted drives. On Linux, USBGuard does the same job with device rules. Test the allowlist with the exact drive you plan to use before you roll it out.

How do I undo a USB lock?

Reverse the method you used. Set the Group Policy setting back to Not Configured and run gpupdate /force, set the USBSTOR Start value back to 3 and restart, re-enable the controller in Device Manager, or remove the Linux modprobe file and rebuild the initramfs. Keep a note of which method you used, or you will waste time guessing.

Is locking USB ports enough to stop malware from USB drives?

No. It is one layer. Keep antivirus and real-time protection on, keep Windows and your apps patched, disable autoplay, and train people not to plug in found drives. CISA ransomware guidance also stresses offline backups, because a single infected drive can still reach a machine through another route.

Sources

  1. Trio — How to Disable USB Ports on Windows, Mac and Linux
  2. NinjaOne — How to Disable USB Drives on Windows 11 and 10
  3. ManageEngine — How to Disable USB Devices Using GPO
  4. CISA — #StopRansomware Guide
  5. ManageEngine — How to Disable USB Storage
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Trio, NinjaOne and ManageEngine step-by-step guides for Windows Group Policy, registry and Device Manager methods, plus CISA ransomware guidance.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free