That is the million dollar question, and it is as hard to answer in some ways as it is to figure out who the good teachers are. Rankings like you see on websites and such don’t have much value IME, because they reflect only those who compile them, and may not reflect anything. Music students tend to network these days, and as a result they often will get to know about teachers from kids who have studied with them. Music festivals are another source, someone is associated with the festival, and you find that you click with them. Primary teachers usually will suggest people, and if you start looking at bios of working musicians, often you will see who they studied with. Working musicians are often good sources, because they are in the mix, they see a lot of musicians, and tend to see where the good ones are coming from.
All that is preliminary, from there as others have suggested it comes down to the student and how they interact with the teacher, and the way to find that out is sample lessons.Yes, people have chosen teachers basically without doing sample lessons and more than a few of them have done just fine, but teaching is very much a one to one relationship, and one size doesn’t fit all. If there is any way to do lessons with a potential teacher, do it, because it is a vital part of the process.