Harbours are, on the whole, far too easy to get into full stop. This is especially evident for larger and more important ports. It should be virtually impossible to get into Tokyo harbour, for instance, without real problems.
There are a couple of things, off the top of my head, that could be done to improve things; For assigned objectives, (Harbour recon mission, for instance.) random ship groups could be spawned within that particular mission which are not at dock but have their speed reduced to a very, very small amount so that, for all intents and purposes, they are at anchor but once something happens they are able to get up steam. This would work nicely for harbour defence ships. For the campaign in general this would probably be less effective as it would work better over a limited time span but you never know.
Coastal defences, minefields and subnets are still the best idea I think for stiffening up the ports. It is a lot of work but it really is the best option. Mind you, I would (and I am going too,) reduce the amount of shipping available in a lot of the ports., contrentrate more in convoy - naval hubs and add neutrals. I would also like to scale up the defences in relation to the merchent presence. Eg: I went into a harbour the other day which had at least 12 ships in it, many of them oilers and the bigger marus. Now, surely in real life such a concentration of high value targets is going to be heavilly defended by patrol craft, possibly destroyers and probably aircraft. What did I see? One gunboat and a destroyer at anchor.

If I had had more than 4 torps left (and two of them were duds,) I could have done in ten minutes what it would have taken about 5 patrols to achieve in real life.