The important part here is that you do not know what happened to your cat in these two years. He could have been a stray or abused or just generally not have been in a good cat place.
You need to give him time.
Approach this like you would a new cat that does not know you or your home. Give him space and let him come to you if he wants. He needs to relearn that you are not an enemy and that your home is a safe place. Let him hide if he wants to, and do not touch him if he feels uncomfortable.
Keep him inside for a while.
Even if he was allowed outside before, do not let him outside right now. He may be confused and unsure of your home. Teach him that this is his home.
Create opportunities for him to observe you.
Sit on the couch and read or do some simple chores around him. This way he can get used to you again.
Again, give him (and yourself) time.
This get to knowing each other again process could take a few days, a week, or even longer. Do not try to force anything, and just show him that you are friends.