Restart your USB subsystem.
Today, I noticed that one of my MacBook’s USB ports no longer worked. It provided power to my external disk but the OS did not notice the device. So, what to do? Reboot? Sure, would have helped but I was in the middle of a lengthy copy operation (from a network share to my internal drive). So I decided to get adventurous.
The USB subsystem is driven by a kernel extension. I decided to kick the hardware driver and restart it to see if this revives the port. So, open Terminal and:
sudo kextunload -b com.apple.driver.AppleUSBEHCI
It complains that this module is in use but it shuts down (partially) anyways. Now … your keyboard no longer works. Ups. Could have thought of that.
Log in using ssh from your iPhone and:
sudo kextload -b com.apple.driver.AppleUSBEHCI
Cross your fingers … keyboard is back, USB port is back.