What does John 18:17 mean?
Prior verses indicated that John was known to the family of the high priest (John 18:15–16), so when Peter hesitated to come into the courtyard, John was able to get him access. The doorkeeper, however, either recognized Peter's face, or possibly noticed his Galilean accent (Matthew 26:73). Either way, out of suspicion or curiosity, she brings up the possibility of Peter being a follower of Jesus.The phrasing used here is rhetorical. The servant girl expects a "no" answer. In her mind, it would be foolish for someone whose master was under arrest to put himself in harm's way. This was not Jesus' intention, either (John 18:8).
At this point, Peter's posturing takes a dramatic turn. Earlier this same evening, he had claimed willingness to die for Christ (John 13:37). To the credit of his bravery, at least, he attempted to fight back when Jesus was under arrest (John 18:10). And he's secretly followed along to at least see what happens to his Master (Matthew 26:58). Now, under a different kind of threat, and without Christ by his side, Peter gives in to fear. He lies and claims he's not a follower of Christ.
This is what Jesus predicted would happen (John 13:38), and Peter will make this same denial two more times (John 18:25–27).
John 18:15–18 includes the first of Peter's predicted denials of Christ (John 13:36–38). Peter has followed the party who arrested Jesus, obviously at some distance, attempting to secretly see what will happen. Though Peter was brave in attempting to defend Jesus earlier, he shrinks in the face of danger here. Asked to admit his relationship with Christ, he lies. The unnamed disciple here is probably John, who may have been a relative of the priestly family.
Jesus is secretly, quietly arrested in the garden of Gethsemane and taken to a series of sham trials before Jewish leadership. This leads to His encounter with the local Roman governor. Jesus accepts being described as "King" but denies that His current purpose is earthly rule. A mob assembled by Jesus' enemies reject Pilate's attempt to free Jesus. In the meantime, Peter fulfills Christ's prophecy about a three-fold denial.