Police Commissioner Sanusi Rufai said only boys were killed in the attack on the Federal Government college of Buni Yadi, a secondary school in Yobe state, near the state's capital city Damaturu.
The Islamists, whose struggle for an Islamic state in northern Nigeria has killed thousands and made them the biggest threat to security in Africa's top oil producer, increasingly are preying on the civilian population.
Boko Haram, whose name means "Western education is sinful" in the northern Hausa language, have frequently attacked schools in the past.
A similar attack in June in the village of Mamudo left 22 students dead.
The failure of the military to protect civilians is fuelling anger in the north-east, the region worst affected by the four-and-a-half-year-old insurgency. An offensive ordered by President Goodluck Jonathan in May has failed to crush the rebels.