Nodea — logo

SSH key

An SSH key is an authentication method for the SSH protocol based on asymmetric cryptography. Instead of typing a password, the user logs into a server using a pair of mathematically related keys: a private one and a public one. This is a far more secure and convenient way to access remote machines than a traditional password, which is why it's the standard in server administration.

What an SSH key pair involves

The mechanism rests on two inseparable elements:

  • private key — the secret part that stays solely on the user's computer and is never handed to the server; it can be additionally protected with a passphrase;
  • public key — the non-secret part placed on the server in the authorized_keys file; it can be shared without concern.

During login the server sends a random challenge, which the client signs with the private key. The server verifies that signature using the stored public key — a match confirms identity without any secret crossing the network. Keys are generated with the ssh-keygen command, choosing an algorithm such as Ed25519 or RSA.

Practical application

SSH keys are the basis of administrators' and developers' daily work: logging into a VPS and dedicated servers, deploying via Git, automating with Ansible or CI/CD pipelines, where scripts must connect to servers without human interaction.

Their biggest advantage is resistance to brute-force attacks — cracking a key of adequate length is computationally infeasible, unlike guessing passwords. A good hosting practice is to disable password login and allow key authentication only, drastically reducing the risk of account takeover. The private key should be guarded like your most valuable secret and backed up regularly.

Powiązane pojęcia

Najczęstsze pytania

Is an SSH key safer than a password?

Yes, significantly. A key of adequate length is practically impossible to crack by brute force, unlike passwords, which are often weak or reused. Moreover, the private key never leaves your computer and can be protected with a passphrase.

What if I lose access to my private key?

Without the private key you can't log into a server configured for key authentication. That's why it's worth keeping a secure backup and an alternative access method — such as a rescue console from your VPS provider, through which you can upload a new public key.