Most people who've done time in New York City jails can't wait to get away. But on Friday, authorities accused one former inmate of sneaking back in.

Yonkers resident Matthew Matagrano was arrested at a Bronx courthouse and charged with impersonating a Department of Corrections investigator.

Officials say that for at least a week, Matagrano allegedly used phony credentials to get into multiple city lockups, including Rikers Island and the Manhattan Detention Center, where he mingled with inmates for hours.

A criminal complaint accuses Matagrano of using an all-access pass to get through security checks, stealing a walkie-talkie and smoking cigarettes with inmates.

A spokesperson for the Department of Corrections said authorities discovered Thursday that someone had gained unauthorized access to the jails by impersonating an employee, and that within hours, officials were able to identify Matagrano through surveillance cameras.

The 36-year-old Matagrano is a registered sex offender with a lengthy rap sheet that includes convictions for sodomy and sexual abuse.

He had previously been caught posing as a Board of Education worker to enter two schools and rifle through student files. In 2004, he pleaded guilty to attempted burglary in connection with that case.

Weird News Photos: Man Busted With 41 Pounds of Pot

A judge set bail at $50,000. In addition to the impersonation charges, Matagrano faces charges of burglary, possession of forged instruments, larceny and promoting prison contraband. He is due back in court Wednesday.