I'd check your tenancy laws, that's certainly not legal in some countries. I would be evicted if I did that.
Are you allowed to install an alarm system and not give him the code?
He is not allowed to enter any time, I guess? Or is he?
http://www.austlii.edu.au/au/legis/vic/consol_act/rta1997207...
"A party to a tenancy agreement who changes any external door or window lock must as soon as practicable give a key to the lock to the other party."
"A tenant who wishes to change a lock in a master key system must obtain the landlord's consent before changing that lock."
Our tenancy law is extremely specific and breaches of it either end in termination, mediation, or disciplinary action against the landlord. It's very effective so long as long as everybody understands their rights and responsibilities. I know of people who've changed their locks and been evicted as a direct result.
http://www.austlii.edu.au/au/legis/vic/consol_act/rta1997207...
Since then I alway change the lock in the main door. This has also the advantage that I can go for something better than what the landlord deems apropriate. Last time I went for EVVA 3KS. Is that still state of the art?
I am not saying this happened here.