From the reference to an animal with green (that is, young) horns
From 17th-century jewellery manufacturing, which used decorated horn impressed at a specific temperature. If heated too high (a common mistake by apprentices), the horn turned green.
From a misappropriation of the German expression "grün hinter den Ohren" (to be green behind the ears).
1847, George Frederick Augustus Ruxton, Adventures in Mexico and the Rocky Mountains, page 267:
The powers of the Canadian voyageurs and hunters in the consumption of meat strike the greenhorn with wonder and astonishment; and are only equalled by the gastronomical capabilities exhibited by Indian dogs, both following the same plan in their epicurean gorgings.