Verdi himself used this idiom in a letter to Countess Clara Maffei:
A period of hard work – producing 14 operas in all – followed in the fifteen years after 1843, right up through the composition of Un ballo in maschera, a period which Verdi was to describe as his "years in the galleys" in a letter to Countess Clara Maffei: "From Nabucco, you may say, I have never had one hour of peace. Sixteen years in the galleys".
This implies a life of unrelenting work, such as sailors might endure in the Navy.
There's a note in the Wikipedia article:
Philip Gossett, "Giuseppe Verdi and the Italian Risorgimento", Proceedings of the American Philosophical Society, Vol. 156, No. 3, September 2012: Gossett notes: "Yet Verdi's only use of the expression is in a letter of 1858 to his Milanese friend Clarina Maffei, where it refers to all his operas through Un ballo in maschera: it laments the social circumstances in which Italian composers worked in the mid-nineteenth century, rather than judging aesthetic value."