As spoilsofwar stated, they are stuffing boxes (also called packing glands) and they probably don't need to be replaced, just adjusted or repacked. The packing nut (largest nut close to the transmission) needs to be tightened to reduce the water coming in. The smaller nut serves as a lock nut to keep the packing nut in the correct place. You will need two large adjustable wrenches, water pump pliers or pipe wrenches to turn the two nuts in opposite directions in order to unlock the packing nut and then you can tighten it up until the water drips once every minute while the shaft is turning. If you cannot slow the water from flowing in by adjusting the packing nut, the packing material inside of the stuffing box needs to be replaced. This is a regular maintenance item and is stocked at marine suppliers, it is basically woven line impregnated with a lubricant and comes in different diameters and is cut to length to fit. There are some newer materials available that can be tightened further to withstand less leakage. As spoilsofwar mentioned there needs to be some water coming in, it is necessary to keep the packing from overheating which would cause the stuffing box to seize to the shaft (very bad). There is a dripless system that uses a seal instead and circulates water to cool the fitting but I don't think that is what you have.
This photo shows what the stuffing box looks like apart, if the boat was in the water, water would be rushing in like mad. The packing can be changed without hauling the boat but you have to have to be prepared to work quickly and not panic, the packing material should be cut to length such that it is one complete wrap around the shaft, use multiple pieces and offset the ends, if you try one continuous piece wrapped around multiple times, it will not tighten up correctly and will leak.
