Allah the Almighty commands:
“Do not approach fornication. It is definitely an outrageous act and an evil way.” (The Night Journey 17:32)
Shaking hands with people from opposite sex is considered in two aspects:
1- Common usages like during meeting, greeting, making an agreement, etc.
This kind of handshaking is permitted as it doesn’t involve an approach to an unlawful relationship.
2- Exceptional kinds like holding, squeezing, patting, kissing the hand, etc.
These kinds are not permitted as it involves an invitation to intimacy.