No, Jesus is not a works-salvationists and just like Roman Catholics and other works-salvationists, you misinterpret the passage to support salvation by works. Jesus knows the hearts of all men and responds to each individual a little differently because He knows where their need is. He didn't respond to the woman at the well, or to Nicodemus or to the rich young ruler the exact same way, yet the consistent pattern in scripture is salvation by grace through faith, not works (Ephesians 2:8,9).
Jesus showed the rich young man how short he falls of keeping the first commandment (Exodus 20:3) which is the first of the two great commandments (Deuteronomy 6:5; Matthew 22:37). The rich young man confidently and (self righteously) declared that he has kept the commandments from his youth up and qualified for heaven under those terms. Yet Jesus knew the man's wealth had become his idolatrous god, which kept him from believing in Jesus.
The rich young man missed the point that Jesus was making (as did you) and failed to place his faith in Jesus for salvation, and continued instead to trust in his riches (vs. 21-23). The rich young man went away sad because he could not part from his great wealth, not even in exchange for eternal life.
If keeping the commandments is the basis by which we receive eternal life, then why isn't this remark the pattern for all discussions concerning eternal life? Paul would have said to the jailer who asked, "what must I do to be saved?" by replying in Acts 16:31 - keep the commandments, yet that's not what Paul said. Instead, Paul said -
"Believe on the Lord Jesus Christ and you will be saved." *We see this throughout scripture - (John 1:12; 3:15,16,18,36; 5:24; 6:29,40,47; 11:25,26; Acts 10:43; 13:39; Acts 15:7-9; Romans 1:16; 3:22-28; 4:5-6 etc..). What we don't see is salvation by works (Romans 4:4-6; Ephesians 2:8,9; Titus 3:5; 2 Timothy 1:9 etc..).
We have here a command of Jesus to go and make disciples of all nations, then baptize them and teach them to observe all things that Jesus has commanded them NOT as a means of becoming saved but BECAUSE they are already saved. Don't put the cart before the horse.
Jesus is not a works-salvationists because the one who are obeying His teachings have already been saved through faith.
So in Hebrews 5:9, who obeys Him? The saved or the lost? Hebrews 5:9 is yet another commonly used verse that I've heard many works salvationists use in an effort to try and support salvation by works (including Roman Catholics, Mormons and Campbellites). *Only believers have obeyed Him by choosing to believe the gospel (Romans 1:16)
in order to become saved, and only believers obey Him after they have been saved through faith by keeping (guarding, observing, watching over) His commandments and practicing righteousness and not sin (1 John 2:3; 3:9,10).
*In either sense, only believers obey Him.
Unbelievers have not obeyed Him by refusing to believe the gospel (Romans 10:16) and
without faith its impossible to please God (Hebrews 11:6), so unbelievers do not obey Him no matter how much "so called" obedience that they attempt to conjure up through the flesh in a vain effort to receive salvation by works.
*So in either sense, unbelievers do not obey Him.
No, they are His disciples who are obedient to God BECAUSE they are saved and not in order to become saved by works.
Scripture.
Oh the irony.