View more videos at: http://nbcnewyork.com.

New York State Criminal Justice Services / AP Matthew Matagrano

A New York-area man who snuck into jail for visits may soon get the chance to become a permanent resident.

Yonkers, New York, resident Matthew Matagrano was arraigned Saturday on charges that he impersonated a Department of Correction investigator so that he could gain access to prisons, including Rikers Island and the Manhattan Detention Center.

Once inside, the 36-year-old gave cigarettes to inmates and smoked them in the common areas. Matagrano himself had been locked up for a rap sheet that includes sodomy and sexual abuse, and he is a registered sex offender.

New York City officials says that for at least a week Matagrano had been using fake credentials and a uniform to gain access to prisons where he would hang out with inmates. A surveillance camera caught Matagrano during one of his visits, according to a criminal complaint. Upon entry, he said he was an investigator from the department’s intelligence unit.

It’s unclear why he wanted to break into jail, but this is not the first time Matagrano pretended to be something he’s not to gain access. He had previously been caught posing as a Board of Education worker so that he could get into two schools and look through student records. He pleaded guilty in 2004 to attempted burglary.

It’s also unclear why someone with a criminal past could so easily gain access to prisons. A spokesperson for the Department of Corrections told NBCNewYork.com only that “The apprehension this afternoon of Mr. Matagrano occurred within 24 hours of the department learning of the matter.”

The investigation is ongoing and there may be uncovered that Matagrano snuck into even more New York-area prisons.

He is charged with burglary, possession of forged instruments, larceny and promoting prison contraband. A judge set bail at $50,000.

The Associated Press and NBCNewYork contributed to this report.