In this work we study the effect of hydration on the dynamics of a protein in confined geometry, i.e. encapsulated in a porous silica matrix. Using elastic neutron scattering we investigate the temperature dependence of the mean square displacements of non-exchangeable hydrogen atoms of sol-gel encapsulated met-myoglobin. The study is extended to samples at 0.2, 0.3 and 0.5 g water/g protein fractions and comparison is made with met-myoglobin powders at the same average hydration and with a dry powder sample. Elastic data are analysed using a model of dynamical heterogeneity to take into account deviations of elastic intensity from gaussian behaviour in a large momentum transfer range and reveal a specific, model independent, effect of sol-gel confinement on protein dynamics, consisting mainly in a reduction of large-scale motions that are activated at temperatures larger than approximately 230 K. Surprisingly, the effect of confinement depends markedly on hydration and has a maximum at about 35% water/protein fraction corresponding to full first shell hydration. The presence of hydration-dependent MSD also in encapsulated met-Mb strongly supports the idea that the effect of sol-gel confinement on protein dynamics involves a modification of the structural/dynamical properties of the co-encapsulated solvent more than direct protein-matrix interactions.