The trick in our verse is first of all to find the main verb. There are two indicative verbs,
ὀφείλει and περιεπάτησεν. Next, find the subject of each. The subject of περιεπάτησεν
is easy to identify: ἐκεῖνος. The subject of ὀφείλει is the participial phrase ὁ λέγων ἐν αὐτῷ
μένειν, the infinitive, completing the thought of the participle.
If you go word for word, though, you don't really have English, and it won't indicate that λέγων
is actually "claiming" to be. "The one who claims to remain in him" [Jesus]. You could translate
λέγων as "says," but you would have to rely on context to see that John is not saying the
person may actually not remain.
The other two tricky words are αὐτός and περιπατεῖν. What is αὐτός doing? It is repeating
the subject of ὀφείλει. "He" is the one who claims he remains in Jesus. αὐτῷ and αὐτός refer
to two different people, which is part of the confusion.
What then is ὀφείλει doing? Despite the intervening words, it is completing the thought of
ὀφείλει. the person who claims to remain in Jesus to walk as Jesus walked. Word for word
John says something like, " The one saying to remain in him [Jesus] ought, just as that one
[Jesus] walked, so also he in the same way walk." Hardly English.
The translations here are interesting. The NIV smooths out the grammar. "Whoever claims
to live in him must live as Jesus did." The CSB also smooths out the grammar: "The one
who says he remains in him should walk just as he walked." Note that is does not actually
translate the words "καὶ αὐτὸς οὕτως" except that "as" translates οὕτως. The NASB's use of
capitalizing divine pronouns helps: "the one who says he abides in Him ought himself (αὐτός)
to walk in the same manner as He (ἐκεῖνος) walked."
If you want to see a screencast on this verse, check out 1 John 2:6 on the second year online
Greek class I am creating.