A group of young British computer hackers who masterminded sophisticated cyber-attacks on major global institutions from their bedrooms have been given the longest ever jail sentences for hacking.

LulzSec "hacktivists" Ryan Ackroyd, Jake Davis, Mustafa Al-Bassam and Ryan Cleary masterminded cyber-attacks on major global institutions including the CIA, Sony, the FBI and Nintendo. The collective was behind attacks that stole sensitive personal data including emails, online passwords and credit card details belonging to millions of people.

News International, the NHS and the UK's Serious Organised Crime Agency (Soca) were also victims of the group, who lived as far apart as London and the Shetland Islands and never met in person.

Sentencing them at Southwark crown court in London on Thursday, Judge Deborah Taylor said some of their taunting of their victims "makes chilling reading".

What they considered a cyber game, she said, had in fact 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.

Stolen information was posted unencrypted on their website and file-sharing sites like Pirate Bay in 2011, the court had previously heard.

They also carried out distributed denial of service (DDoS) attacks, using linked networks of up to 1m computers to overpower and crash websites.

Their activity collectively cost their targets millions of dollars and potentially left millions of people at risk from criminals.

All admitted offences under the Computer Misuse Act 1990.

Cleary, 21, of Wickford Essex, known as ViraL, pleaded guilty to six charges including hacking into US air force computers at the Pentagon.

He was jailed for a total of two years and eight months.

Ex-soldier Ackroyd, 26, from Mexborough, South Yorkshire, was jailed for 30 months having previously pleaded guilty to one charge of carrying out an unauthorised act to impair the operation of a computer.

The Iraq veteran used the online persona of a 16-year-old girl called Kayla.

Bassam, 18, from Peckham, south London, used the alias tFlow. He was at school at the time and is currently sitting his A-levels, the court heard.

He was given a sentence of 20 months suspended for two years, plus 300 hours of community work.

Davis, 20, from Lerwick, Shetland, used the alias Topiary and was LulzSec's main publicist. He was ordered to serve 24 months in a young offender institution.

He and Bassam had previously pleaded guilty to hacking and launching cyber-attacks on a range of organisations, including the CIA and Soca.