For years, I used my dockside water hook up as my primary source of water. Now that I have a decent 110v fresh water pump, I'm using the tanks, instead. Still, I have to bring dockside water into the boat in order to fill the tank since my tank-fill is all the way aft and there is no way to walk back there with a hose on the outside. I have a spigot on the aft deck that I use. So, I still have my set-up.
I have an on/off valve screwed into the boat's dockside water inlet and the hose screwed into that. It's just a simple twist valve that you can find in any garden section of any hardware store. When I'm on the boat, I turn it on and I turn it off when I leave. With my shutoff right at the PH door, I never have to run out to the pedestal to shut off the water which is pretty nice when I get caught in the middle of something like a shower or doing dishes and I run out of tank water - I simply open the door, reach down and turn the valve. As for your situation, this would work, but only to the extent that someone remembers to shut the water off every time they leave the boat. I don't think there is anything that is completely "automatic" for your situation, meaning someone will either have to reset the timer from time to time or remember to turn the water on/off. I've never had an issue with dockside water being on the boat, and over the years, I've only forgotten to turn it off maybe 5 times in 6 years. It's been part of my rountine upon leaving the boat, just like locking the door when I leave. Granted, I live on the boat and am never gone for more than about 9 hours at a time. And, my bilge pumps outrun the dockside water pressure. The thought of having dockside water on the boat does bother some people, but I've never been scared of it, yet.
If you go the way of the timer, you can put it onto the boat's water inlet and if the thing times out, it's convenient to reset it. You could also use the timer in that location and just make resetting it a part of your exiting the boat routine.