U.S. federal agencies and ministries, including the Treasury and Commerce departments, were spied on by hackers suspected to work for the Russian government, officials have acknowledged after media reports.