Due to the critical resource constraints of wireless sensor nodes such as processing speed, memory size and energy supply, implementing security mechanisms, in particular key management schemes, is quite challenging. Motivated by the conference key establishment scheme proposed by Harn and Gong in [11], we propose LPKM (Lightweight Polynomial-based Key Management Protocol), a key management scheme for distributed WSNs. LPKM enables sensor nodes to establish different types of keys to bootstrap trust and secure one-to-one and one-to-many communications in a flexible, reliable, and non-interactive way. Moreover, LPKM can effectively mitigate or thwart the most common attacks to WSNs such as node clone attacks, node impersonation attacks, etc. In addition, LPKM can tolerate changes of network topology and incurs little computational and communication overhead. Our experimental results on MICAz motes show that LPKM can be efficiently implemented on low-cost sensor nodes. In particular, a MICAz mote running at a frequency of 8MHz can generate required group keys of 128-bit in a few milliseconds, at a cost of 6.12 KBytes ROM and 68 Bytes RAM.