Mr Ki-moon, in a message in New York, also expressed his heartfelt condolences to the families of the victims who lost their lives in the terror attacks in the countries.
The Secretary-General said he was dismayed by the attacks and strongly condemned the pattern of attacks against innocent civilians, including women and children, by militant groups and terrorists.
Mr Ki-moon said the perpetrators of the despicable acts of violence must be brought to justice.
He further called for more commitment by the governments of the countries and the international community in the war on terror.
For over five years Nigeria has continued to witness several attacks mostly in the north-east. thousands have been killed and many have been displaced from the region.
A terrorist group, Boko Haram, has claimed responsibility for most of the attacks. The group is seeking an Islamic State and an end to western education in the region.
A counter-terrorism operation by the Nigerian Armed Forces has been on in the region, with the military promising to end the insurgency.