The correct idiomatic expression is 'know by name,' which means to be familiar with someone's identity. 'Our teacher knows all the students by name' means the teacher can identify each student individually. The other prepositions don't form correct idiomatic expressions in this context.