Running 3-wire fans on 4-wire PWM

New motherboards have 4-pin fan connectors that accept a 3-wire or 4-wire plug. The fourth wire is for speed control, a nice feature if you’re trying to quiet things down. But what to do when you can’t find any 4-wire heatsink/fans to fit your CPU?

My computer uses a pair of Dynatron A86G 2U server heatsinks with 50mm fans. These do an excellent job of keeping the CPUs cool, but are extremely loud at normal temperatures, and of course the fans are 3-wire types. It turns out, most 2 and 3 wire fans can be speed controlled by applying PWM to the power supply. The disadvantage is that the tachometer signal’s accuracy can be degraded by this approach.

I built a small adapter to try this out. It uses a couple of transistors to switch the power based on the motherboard’s output. These are needed to keep from damaging the motherboard as its the maximum voltage it can switch is around 3 volts. In this circuit it will never see more than about 1.4V.

A schematic of a PWM level shifting circuit

When the PWM signal is pulled to ground by the motherboard, the transistors are driven into cutoff, momentarily interrupting power to the fan. This reduces its speed, but may also interrupt the tachometer signal, resulting in errors in the measured speed. However, a stalled fan (0 RPM) is still correctly detected.

SSH smartcard authentication

A few months ago I picked up a GnuPG smartcard (available from Kernel Concepts) with the intention of using it for SSH authentication. Today I finally got around to making it work! Here’s how I did it on my Debian laptop.

First, install a few packages: sudo apt-get install pcscd gnupg-agent scdaemon. Run gpg --card-status to make sure it sees your card. gpg --card-edit will drop you into a shell where the card can be initialized. Type admin at the prompt to enter administrative mode, then generate to generate some RSA keys. It’s recommended to back up the private key to an encrypted file in case the card is ever lost or destroyed. Once that’s done, use the passwd command to change the card’s default PINs.

Now a couple configuration files need to be edited. Edit ~/gnupg/gpg.conf and uncomment the use-agent line. Add a line enable-ssh-support to ~/gnupg/gpg-agent.conf (create this file if it isn’t already there). Restart your X session, then run ssh-add -L. If all the magic is working properly, the card’s SSH key should be printed in your terminal.

Paste this key into the authorized_keys file everywhere you want to log in, just like any other SSH public key. Now, the first time you make a SSH connection after plugging in the card, you’ll be asked for the card PIN; additional connections Just Work(tm).