The five were convicted of attacking a freight ship in the Gulf of Aden in January 2009.
Prosecutors asked for a seven-year sentence, but the judge said he took into account the difficult conditions in Somalia that led the men to piracy.
"It is a lucky coincidence that nobody was killed or wounded" in the attack, said judge Klein Wolterink.
Kenya has convicted 18 pirates since 2007. More than 100 await trial there.