We obtain generalised trace Hardy inequalities for fractional powers of general operators given by sums of squares of vector fields. Such inequalities are derived by means of particular solutions of an extended equation associated to the above-mentioned operators. As a consequence, Hardy inequalities are also deduced. Particular cases include Laplacians on stratified groups, Euclidean motion groups and special Hermite operators. Fairly explicit expressions for the constants are provided. Moreover, we show several characterisations of the solutions of the extension problems associated to operators with discrete spectrum, namely Laplacians on compact Lie groups, Hermite and special Hermite operators.2017 Leonardo grant for Researchers and Cu...