About a dozen youths tried to break into the barracks in the Indian Ocean town of Nyali at around 5:30 am (local time), the army said in a statement.
"Soldiers... Responded, killing five of the men. The sixth was pursued and shot dead in a nearby forest."
The army said one soldier was hacked with one of the attackers' machetes and was being treated for his injuries.
There was no immediate information about the identity of the attackers.
Also Read
Kenyan troops are fighting the extremists in Somalia as part of an African Union force.
Mombasa County Commissioner Nelson Marwa said the assailants were met with "fierce fire" even though the soldiers were probably sleeping when the attack started.
"How on earth would a gang of criminals in their normal minds want to raid an army barracks, in an independent country," he said.