A man has been charged with hacking the Apple iCloud and Gmail accounts of celebrities and stealing nude photos and videos from them.

The US authorities say Ryan Collins has agreed to plead guilty to the offence.

Prosecutors have recommended that he face a jail term of 18 months, although a judge could extend that to five years.

The 36-year-old is alleged to have stolen usernames and passwords via a phishing scam.

The Department of Justice said that the Pennsylvania-based Collins had admitted to breaking into more than 100 accounts between November 2012 and September 2014.

He is said to have achieved this by sending emails to the victims that pretended to be from Google or Apple requesting their login details.

“[The] defendant used numerous fraudulent email addresses designed to look like legitimate security accounts from various internet service providers, including, for example, [email protected], [email protected] and [email protected],” said court filings.

Collins is accused of accessing at least 50 iCloud accounts and 72 Gmail accounts.

Once he had fooled their owners into handing over their details, prosecutors say, he searched through the victims’ online data.

“Through his phishing scheme [the] defendant was also able to access full Apple iCloud back-ups belonging to numerous victims, including at least 18 celebrities, many of whom reside in the Los Angeles area,” the court papers state.