The hackers, who were affiliated with the group Lulz Security, had all pleaded guilty to hacking charges. Prosecutors say they also targeted the websites of Britain's National Health Service and the U.K.'s Serious Organized Crime Agency, and posted stolen information including emails and credit card details belonging to millions of people on file-sharing sites like Pirate Bay in 2011.
The group also attacked their targets by launching distributed denial of service attacks, which overwhelm sites with traffic.
Sentencing the four, Judge Deborah Taylor said what they considered a "cyber game" had real consequences.
"You cared nothing for the privacy of others but did everything you could through your computer activities to hide your own identities while seeking publicity," she said.
She gave a 32-month sentence to Ryan Cleary, 21, who pleaded guilty to six charges including hacking into U.S. Air Force computers at the Pentagon.
The others were: Ryan Ackroyd, 26, jailed for 30 months; Jake Davis, 20, jailed for 24 months; and Mustafa Al-Bassam, 18, who was given a suspended 20-month sentence.
Prosecutor Andrew Hadik described the hackers' actions as "cowardly and vindictive" and said they caused companies serious financial and reputational damage.
"Coordinating and carrying out these attacks from the safety of their own bedrooms may have made the group feel detached from the consequences of their actions," Hadik said in a statement. "But to say it was all a bit of fun in no way reflects the reality of their actions."