By default, the list of keys that a user can use to log in to any particular node is stored in $HOME/.ssh/authorized_keys
on the node being logged into.
The private key that the user uses to make connections is stored in the node which originates the connection.
If you want to prevent a user logging in using a particular key, you can simply remove it from their authorized_keys
file. But be aware that the user can always put it back themselves, if they can log in to that node or otherwise access that file. You can also change the path to the authorized keys file by setting AuthorizedKeysFile
in /etc/ssh/sshd_config
to a file which the user cannot access. But keep in mind that this will apply to all users.
As for determining how a user authenticated, that information is in your log file /var/log/secure
. For example:
# grep Accepted /var/log/secure Nov 26 03:13:46 www sshd[13925]: Accepted password for user1 from 203.0.113.242 port 3481 ssh2 Nov 26 03:20:22 www sshd[14216]: Accepted publickey for dev2 from 198.51.100.21 port 64386 ssh2: RSA SHA256:...omitted...