This is what typically happens in a client-server environment, when a user on the client tries to gain access to the server using public-key authentication:
The client requests access from the server to a specific user account, and also sends the public key it wishes to use for authentication to the server.
The server checks whether the public key is associated with the user account.
The client signs a known value with the user's private key. The known value is unique to a session to prevent replay attacks.
The server verifies the signature with the user's public key.
If the signature is successfully verified, the user is authenticated, and the server can move on to authorizing the user, or giving access to the relevant parts of the system.
Public-key authentication is often used both ways so that two hosts (a client and a server) authenticate each other mutually via their public and private keys. Server host key pairs typically do not have their private keys protected by a passphrase, as they must be operated non-interactively.
Whereas the initial process of associating an entity with a public key is referred to as identity establishment, Steps 1–4 in the above list are referred to as identity checking, and they are performed every time when public-key authentication is attempted. Step 3 is often referred to as proof of possession. The entity proves that it is the owner of the public key by showing that it possesses the private key.
The identity checking in public-key authentication is stronger than in password authentication. When using password authentication, knowing the password is enough. Public-key authentication requires both knowing the passphrase and having the private key. This dependency on two separate elements to ensure security in public-key authentication is referred to as two-factor authentication. In comparison, password authentication is only a one-factor authentication scheme, as it depends only on the password.
In both cases, however, security relies on identity establishment. If a password is given to the wrong person, or if a wrong public key is associated with a user account, the strength of the identity checking will not keep unauthorized users out.