The SSH protocol can be used to securely connect to a remote computer. SSH access can be enabled in OS X by going to Preferences –> Sharing –> checking Remote Login On.
There are many client applications that can be used to connect to a computer running SSH (see here). When connecting to a computer over SSH a secure client application should ask to verify the key. The key is used to verify that the machine being connected to is the intended one. The OS X SSH key can be displayed by using the Terminal, which is located under Applications –> Utilities. After opening Terminal type:
ssh-keygen -l -f /etc/ssh_host_rsa_key
The key will be displayed as 16 hexadecimal characters separated by colons. If the string displayed by the SSH client does not match the one displayed in Terminal then it is likely there is a man-in-the-middle attack occurring and the connection should be terminated.