A former educator who worked in four Long Island school districts over more than two decades and pleaded guilty last year to a child pornography charge was sentenced Tuesday to 5 years in prison.

Kevin O’Connell, 55, who had admitted to downloading child pornography and keeping the images on thumb drives in his Patchogue home, was sentenced by U.S. District Judge Leonard Wexler at the federal courthouse in Central Islip.

After he gets out of prison, he must serve 5 years of supervised release, prosecutors said. He also must register as a sex offender, and he will not be allowed to have unsupervised contact with minors, they said.

O’Connell was assistant superintendent of secondary education for Roosevelt schools at the time of his arrest in October 2012.

Before that, he was principal of Bellport High School in the South Country school district and an assistant principal at Walter G. O’Connell Copiague High School in Copiague. From 1990 to 2001, he was the varsity baseball coach at William Floyd High School in Mastic Beach.

“Keeping our children safe is a priority for law enforcement and this office,” said Robert L. Capers, U.S. attorney for the Eastern District of New York. “This crime was particularly egregious in that O’Connell, as an educator, a former high school principal and a coach, was entrusted with ensuring the safety and well-being of children while he at the same time was victimizing children by receiving images of children being sexually abused.”

advertisement | advertise on newsday

O’Connell’s attorney, Glenn Obedin of Central Islip, did not return a call for comment.

The school districts did not return requests for comment.

Prosecutors said O’Connell had downloaded video files of the rape and abuse of children as young as 8 years old, keeping the material on thumb drives in his Patchogue home.

According to court filings and facts presented at his guilty plea and sentencing proceedings, he initially lied to agents from the U.S. Department of Homeland Security during a court-ordered search of his residence on Oct. 15, 2012, denying he possessed child pornography. But the investigators found three thumb drives in the pocket of a jacket at the house, and O’Connell admitted he had hidden the drives there, prosecutors said.

The federal agents had executed a search warrant at the residence after they traced an internet address advertising three video files available for sharing to O’Connell’s home, according to the federal complaint in the case.

The prosecution was part of Project Safe Childhood, a nationwide initiative that the U.S. Justice Department launched in May 2006 to combat the growing tide of child sexual exploitation and abuse. The effort uses federal, state and local resources to better locate, apprehend and prosecute those who use the internet to exploit children.

O’Connell was principal at Bellport High, in the South Country school system, during an unrelated, highly publicized controversy involving a star football player, Ryan Sloan.

In December 2011, O’Connell said he had been fired as the Bellport High principal because he refused to inflate Sloan’s grades so the athlete could get a scholarship to attend Syracuse University.

advertisement | advertise on newsday

An independent investigation found that Sloan’s grades were changed, and former South Country schools superintendent and football coach Joseph Cipp Jr. resigned. Both Cipp and Sloan have repeatedly denied the allegations.

O’Connell filed a wrongful termination lawsuit against the district in state Supreme Court in Suffolk County. A justice dismissed the suit in February 2013, according to court records.