"And as for Seth, to him also a son was born; and he named him Enosh. Then men began to call on the name of the Lord." (Genesis 4:26, NKJV)
The people in the Old Testament were saved or made righteous before God in the same manner as those in the New Testament.
"For there is no distinction between Jew and Greek, for the same Lord over all is rich to all who call upon Him. For “whoever calls on the name of the Lord shall be saved.”" (Romans 10:12-13, NKJV)
This concept of calling upon the name of the Lord is foundational to a right relationship with God. From the very beginning in Genesis men recognized their sinful condition which required forgiveness by God. Becoming righteous before God then is not something you do, rather it is something that God does for you.
"For by grace you have been saved through faith, and that not of yourselves; it is the gift of God, not of works, lest anyone should boast." (Ephesians 2:8-9, NKJV)