Where's the problem?
I guess I have a different take on this "problem". And, that is where's the problem?
For us, at least, we want our male, intact GSD to be territorial and to protect not only the people who live here, but also, the property if we're not here. So, over the past about 19 months of my GSDs stay here we've trained him to bark at any disturbance on the property (door bell, knock, sound of footfalls on the bull rock drainage, talking, laughing, etc.) And, we want him to be suspicious of strangers, particularly those who we might meet and who might accost us on the street.
Actually, it wasn't all that easy to train him to do these things as he came from a breeder who championed even, easy to get along personalities in her dogs. So, he defends with some reluctance still and is often looking to me for encouragement if he starts barking at someone.
We just don't let others come in the house until he's crated (he goes to crate immediately on command). And, we don't allow anyone to come into the back yard without first putting him in his outside pen.
On the street, we as aggressively as needed dissuade people from trying to pet him or interact with him in any way. But I'll admit that he's come to know a couple of neighbors, generally men, that he seems to like a good bit and I'm not perfect in enforcing that rule with them.
For us what you're describing is precisely what we'd have wanted our GSD to do without having to do any training. Just another point of view on the topic.
Oh, my GSD also has a few things about people that seem to put him off. Tatoos, piercings, cowboy hats (although he's cool with baseball hats and other types), a person carrying a yard tool or skateboard, two unfamiliar people at a time approaching him, anyone walking or riding a bike or jogging up behind him, especially in the dark and quick movements (once a young girl wanted to approach him but threw her backpack down to do so scaring the dog).