When we create the SSH key pair and move the public key to the remote system, it works as an authentication method for connecting to the remote system. If the public key present in the remote system matches the public key generated by the local system, and the local system also has the private key to complete the key-pair, the login happens. Otherwise, if any key file is missing, login is not allowed.