This is why many companies have policies prohibiting human accounts from using ssh keys... they tend to share them and/or don't put passwords on them so that the keys themselves basically become passwords-in-a-file.
Smarter companies will use a security product to control which users are allowed to use ssh keys, where those keys can be used, and where the connections are allowed to begin and end.
You are permitting known insecure, unauditable behavior and trying to catch it after-the-fact. The best answer would be to stop the behavior outright.
The same security product that would help you control your ssh key use can also be used to do keystroke logging on the ssh session. That way, you could still capture unique log events, showing the source and destination of the connection and see every ugly keystroke the user typed... with the resulting output. This is a commercial solution, of course, but would definitely get you what you're looking for.
One hack-of-an-option would be to use unique shell history files on each login to the account. Basically you'd define HISTFILE to be something like this in the users .bashrc (or equivalent):
TIMEST=`date +%Y.%m.%d-%H%M%S`
SOURCETERM=` who am i | awk '{print $5}'`
HISTFILE=.sh_history-$TIMEST"_"$SOURCETERM
This results in a unique shell history file for each session, named something like:
$HOME/.sh_history-2021.09.16-022345_(1.2.3.4)
This might get you what you want, but if the users are wise, they could easily change or delete the file, or assign themselves a different history file.
You're trying to work around an almost impossible problem. From the systems' perspective, the same user is simply logged in twice. Commands, processes, memory, etc. are all owned by one UID and can be manipulated by anyone else with the same effective UID.
Again, the proper solution is to prevent the insecure behavior to start with.
sshd
logs. You can also easily manage access (e.g. disable the key of an employee who leaves the company without affecting others).last
, wtmp) and "personal style", e.g. which commands they used (everyone has their own style), check the shell history (if not cleared or manipulated by a malicious actor) and file change times. If available you can check their host machines' (bash/shell) history with command times, file access of ssh key files etc.