A U.S. State Department employee has pleaded guilty to producing child pornography, in part by using his work-issued cellphone and a secret camera.

Skydance MacMahon of Alexandria, Virginia, worked with a woman in Canada to shoot explicit photos and videos of five children inside her home, federal prosecutors say. MacMahon had the woman set up a clock with a hidden camera in her bathroom. While he was at work at the Foreign Service Institute in Arlington, Virginia, he streamed live video from that camera of the woman and her 9-year-old daughter.

Prosecutors say MacMahon, 44, produced more than 1,000 sexually explicit images of children in Canada, and had thousands of other images and videos in his possession. On Monday, he pleaded guilty to producing child pornography.

Investigators caught MacMahon by following a digital trail, using information from Dropbox, Comcast, Facebook and the app Kik.

First, a sex offender in Hamilton Township, Ohio, admitted to sexually assaulting a 5-year-old girl. He told police in November 2017 that he used Kik to trade images of the abuse for other child pornography. He gave his phone to police, and they found Dropbox folders containing child porn. Many of the images and videos showed a woman and a girl. The folders also included two non-pornographic photos of a man.

Investigators subpoenaed Dropbox for account information, including the users' IP addresses. One account was linked to an IP address at the Foreign Service Institute and a second IP address elsewhere. Law enforcement subpoenaed Comcast to learn the second location. It was the Alexandria home of a woman called J.M. in court documents.

Then, public Facebook pages helped investigators.

Authorities found J.M.'s Facebook page and saw photos of the man they saw in the Dropbox folder. It was MacMahon. On his Facebook page, officials saw a comment from a woman. Her page showed that she and her daughter were the woman and child in the child pornography in the Dropbox folder. They lived in Halifax, Nova Scotia, the woman's page said.

On March 15, Canadian police arrested the woman, called K.C. in court documents. She told police she had known MacMahon for about 12 years. She said that for about a year, she had sexually assaulted her daughter and made photos and videos for MacMahon.

K.C. told police MacMahon sent her the clock with the hidden camera and told her how to set it up.

On March 16, law enforcement interviewed MacMahon. He admitted to using the hidden camera to watch K.C. and her child. He said he used Kik and Dropbox on his work iPhone and had child pornography in his office at the Foreign Service Institute.

"Skydance MacMahon admitted that the investigators would find and view child pornography in his Dropbox account that remained on his personal laptop currently in his office," court documents say.

MacMahon, who is married with at least one child, told investigators he never touched a child sexually.

According to his LinkedIn page, he graduated from James Madison University in 1995.

MacMahon faces a mandatory minimum of 15 years, and could be sentenced on Oct. 12 to as long as 60 years.

State court records show he's being held in Alexandria.