Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A Pennsylvania man has been charged in the hacking of Apple and Google accounts belonging to more than 100 people, many of them celebrities, officials said on Tuesday.

Between Nov. 2012 and Sept. 2014, Ryan Collins, 36, sent fake emails that purported to be from Apple or Google, and got victims to unknowingly hand over their usernames and passwords, the U.S. Attorney for the Central District of California said.

He then used that information to get into their email accounts, swiping nude photos in some instances, and sometimes downloading full backups from Apple’s iCloud, prosecutors said in a charging document filed Tuesday.

Byers Market Newsletter Get breaking news and insider analysis on the rapidly changing world of media and technology right to your inbox. This site is protected by recaptcha

Police began probing an apparent iCloud hack that resulted in leaked nude photos of Jennifer Lawrence and other celebrities, mostly women, in September of 2014.

Collins, of Lancaster, Pennsylvania, was charged in Los Angeles with violating the Computer Fraud and Abuse Act and has agreed to plead guilty to one count of unauthorized access to a protected computer to obtain information, prosecutors said.

The charge carries a maximum of five years in prison, but prosecutors will recommend a sentence of 18 months, the U.S. Attorney's Office said.

There’s an ongoing investigation into the hacking itself, as well as into the posting of the photos. There has not been any evidence that Collins himself posted any of the photos, or that he was directly involved in leaking them, officials said on Tuesday.

Collins case will be transferred to Harrisburg, Pennsylvania. This is the first arrest in connection with the security breach. At least 50 iCloud accounts and 72 Gmail accounts were compromised, officials said.

"By illegally accessing intimate details of his victims' personal lives, Mr. Collins violated their privacy and left many to contend with lasting emotional distress, embarrassment and feelings of insecurity," David Bowdich, the Assistant Director in Charge of the FBI’s Los Angeles Field Office, said in a statement.

"We continue to see both celebrities and victims from all walks of life suffer the consequences of this crime and strongly encourage users of Internet-connected devices to strengthen passwords and to be skeptical when replying to emails asking for personal information," he said.