Just reproduced the same error and can confirm this is happening on AlmaLinux 9.3. Here is the journal:
Mar 16 16:21:18 test sshd[3787]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0)
Mar 16 16:21:35 test sshd[3821]: Accepted password for root from XX.XX.XXX.XX port 47388 ssh2
Mar 16 16:21:35 test systemd-logind[540]: New session 5 of user root.
Mar 16 16:21:35 test systemd[1]: Started Session 5 of User root.
Mar 16 16:21:35 test sshd[3821]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0)
Mar 16 16:21:45 test sshd[3823]: Received disconnect from XX.XX.XXX.XX port 47388:11: disconnected by user
Mar 16 16:21:45 test sshd[3823]: Disconnected from user root XX.XX.XXX.XX port 47388
Mar 16 16:21:45 test sshd[3821]: pam_unix(sshd:session): session closed for user root
Mar 16 16:21:45 test systemd[1]: session-5.scope: Deactivated successfully.
Mar 16 16:21:45 test systemd-logind[540]: Session 5 logged out. Waiting for processes to exit.
Mar 16 16:21:45 test systemd-logind[540]: Removed session 5.
Happens with all versions, Alma 8 and CentOS 7 as well! The most likely cause I see is that SSH itself handles authentication of remote user whereas login command is made for local system authentication. When you use the login command over SSH, it’s trying to prompt for a username and password on the remote system, but since the SSH session is already established, it doesn’t handle this input correctly, resulting in the termination of the SSH connection.
Thanks @ankesh this makes sense, i can use other alternatives to login.
I am facing one more problem related to login command, sharing the link here if you could have a look.