Can I log in my vps through tor using ssh? Should I have tor daemon installed on the server too? If yes, why?
You can SSH to your server through Tor using two different methods:
Via an exit node, where your connection to your VPS goes into the Tor network at your local machine (where you're SSHing from), goes through the onion layers, goes out an exit node, then travels over the regular Internet from the exit node to your VPS. This doesn't require any configuration changes to your VPS, because as far as it can tell, the SSH connection is coming in from the Internet, the same as always.
Via an onion service, where the entire connection from your client machine to the VPS travels within the Tor network. For this to work, you need to configure Tor on the VPS to provide the onion service, and pass on the data to the SSH daemon.
I believe that this article can solve your problem https://d33onion.com/2019/11/12/how-to-setup-an-anonymous-vps/