Add a user that only has access to computer via ssh
It’s not clear what you gain by preventing log in, but I’ll assume you’ve for a good reason to complicate things.
Removing “other” from the graphical login screen is easy to do and easy to reverse on Catalina and below. Same with ssh, it’s easy to change the log in method and show the username/password or put back “other“.
If you can’t prevent a person with those credentials from sitting in front of the Mac, the first thing that comes to mind is you make a log in item that is a script that logs them out. It will be difficult for them to fix that if you deny them any other credentials to that Mac.
To ssh, you need a home folder and the system to have credentials to validate the password and assign UID/GID etc..
You can set up LDAP or use a network server and have remote accounts, but the design isn’t likely to work for your case or make sense logistically.

https://support.apple.com/guide/server/intro-to-accounts-apdcb06a828/mac

The matrix covers the differences between where a home folder is stored and how local versus network server vs external account validation happens.
The other easy way to have ssh log in without any chance of GUI log in or compromising security is a container. Fire up Docker for Mac and your ssh container is well isolated from the local user accounts.