Linux for Developers Course
Linux for Developers
/
Intermediate

SSH Keys

Definition

An access credential used by the SSH protocol, based on public-key cryptography. A key pair consists of a Public Key (which you put on the server) and a Private Key (which never leaves your laptop).

Explain Like I'm New

A digital padlock and a physical key. You put the padlock (Public Key) on the server's door. You keep the key (Private Key) on your laptop. When you connect, they mathematically match, and you are let in without typing a password.

Real World Example

You generate a key pair on your Macbook using `ssh-keygen`. You copy the `.pub` (public) file to GitHub. Now, whenever you `git push`, GitHub verifies your private key mathematically and accepts the code without asking for your password.

Common Use Cases

  • •Passwordless logins
  • •Automated deployment scripts (CI/CD)

Interview Questions

basic

  • Which key is safe to share with the world: the Public key or the Private key?

intermediate

  • What is the specific name of the file on a Linux server where you must paste your Public Key to allow access?

Flash Cards

Question

Which is safe to share?

Click to reveal answer
Answer

The Public key. It can only be used to *lock* or verify. The Private key must NEVER be shared with anyone, ever. If someone steals it, they are you.

Question

Which file on the server?

Click to reveal answer
Answer

`~/.ssh/authorized_keys`.