Do you need to know or want to know? I mean that in a technical sense, because without root access on the remote machine ("machine1" in your setup), there's no way to know authoritatively. However, you may be able to make reasonable guesses. That helps if it's informational, but is no good for security.
The ident
daemon was the old-fashioned way of running that, but since in the current world there's no sense in just handing out user information for free to untrusted sites, modern identd implementations usually give an encrypted result. This can be decrypted using a secret kept on the system itself. But even more often now, people just don't run an ident daemon at all.
If you have root on machine1, you can run identd with encryption and use the secret on machine2 to find your answer. Or you can do the netstat
stuff larsks suggests. But if you don't have root, you can look at processes not-as-root and make educated guesses based on timing.
Alternately, you can approach the question from a different angle. If identity assurance is your concern, some type of time- or counter-based cryptographic OTP solution might make it so you can be reasonably sure the remote users connecting are the ones they're supposed to be, no matter what they connect to.