Yup. And an interesting detail is that we know the product G·M_e (where G is the gravitational constant, and M_e is the mass of the earth) to much higher precision than we know either of its factors. And the same goes for the sun and most of the other planets.
This is because the motion of celestial bodies and spacecraft is dominated by gravitational forces which depend only on G·M, and that motion can be measured extremely accurately with e.g. Doppler radar.