Abdi Esa, 21, killed John Smith, 26, at Brinsford Young Offender Institution in Staffordshire in December after he became paranoid that other inmates on his wing were racially abusing him.
Esa, who was in custody for stabbing a classmate at college, attacked Mr Smith with a "haymaker" which knocked him into the door of his cell and then to the floor, breaking his jaw and causing fatal head injuries.
He pleaded guilty to Mr Smith's manslaughter and was sentenced at Stafford Crown Court to two years and three months in detention and an extended licence period of one year.
But the Attorney General's Office challenged the sentence as being "unduly lenient" and, following a hearing on Friday, Esa's sentence was increased to six years.
Paul Jarvis, representing the Solicitor General, told the court that Esa came up behind Mr Smith, meaning he "did not have a chance to defend himself".
Esa "boasted" that he intended to hurt Mr Smith and said the attack "should be a warning to anyone else who was thinking of crossing" him as he was taken away to an isolation wing, Mr Jarvis told the court.
But Esa later expressed "genuine" remorse when he was told Mr Smith had died and told a probation officer that he only attacked him so he would be transferred to another wing, he added.
Mr Jarvis argued that the original sentence was "significantly too short" to reflect the seriousness of the offence.
John Lucas, for Esa, said his client was "a very young man who has had a very sad background".
He added: "This is very, very unlucky... but to punish this young man who is at such a crucial time of his life with a more draconian sentence would be wrong."
Lady Justice Macur, sitting with Mr Justice Johnson and Judge Martin Picton, increased Esa's sentence to six years, with an extended licence period of four years.
She said that after the attack Esa had made "a deliberate show of swagger for the benefit of others", but that "the bravado did change to remorse and contrition once he understood the fate of John Smith".
After the hearing, Solicitor General Lucy Frazer QC said: "Esa's cowardly attack led to the death of a fellow prisoner, who had no chance of defending himself.
"I chose to refer his sentence because I felt that it was too low. I hope that the Court of Appeal's decision brings some comfort to John Smith's family."