# known_hosts

> A file on your computer with each server's key. SSH uses it to spot a fake.

**Field:** Infrastructure  
**Category:** SSH & Remote Access  
**Also known as:** known_hosts File, ~/.ssh/known_hosts, Known Hosts

## Think of it like

Think of it like a guest book of faces. Next time someone comes, you check the book.

## Definition

known_hosts is a file on your own computer that lists the servers you trust. It sits at ~/.ssh/known_hosts. Each line holds a server's address and its host key. SSH adds a line the first time you say yes to a new server. On later logins it checks the key against this line.

## Example

Emma's server was rebuilt on purpose. She removes its old line with ssh-keygen -R, then logs in and trusts the new key.

## Example code

```console
$ ssh-keygen -R 203.0.113.10
# Host 203.0.113.10 found: line 4
/home/emma/.ssh/known_hosts updated.
```

Remove the old key for one server. The next login asks you to trust the new one.

## Why it matters

It is your memory of which servers are real. Without it, SSH could not warn you about a fake.

## Common mistake

Deleting the whole file to stop a warning. That throws away every saved key, not just the one that changed.

## Three principles

- **Your side.** Lives in your .ssh folder.
- **One line per server.** Address and host key.
- **Remove one line.** Use ssh-keygen -R.

## Related terms

- [SSH Host Key](https://learn.benibix.com/term/infrastructure/host-key)
- [Secure Shell (SSH)](https://learn.benibix.com/term/infrastructure/ssh)
- [ssh-keygen](https://learn.benibix.com/term/infrastructure/ssh-keygen)
- [Hidden File (Dotfile)](https://learn.benibix.com/term/infrastructure/hidden-file)

## Told apart from

- [known_hosts vs authorized_keys](https://learn.benibix.com/compare/known-hosts-vs-authorized-keys): People often think both files hold the same keys. They face opposite ways. known_hosts is on your computer and lists the servers you trust. authorized_keys is on the server and lists the people it lets in. One proves the server to you, the other proves you to the server.

## Taught in

- [SSH Host Keys and known_hosts](https://learn.benibix.com/learn/infrastructure-ssh/ssh-host-keys-and-known-hosts): SSH, 2/9

![Three rows. First visit: the server shows its host key and the laptop saves it in known_hosts. Later visit: the server shows the same key, it matches the saved one and the login goes on. Changed key: the key does not match, and the laptop stops with a warning that the host may not be the real one.](https://learn.benibix.com/diagrams/inf3-host-key.svg)

---

Source: https://learn.benibix.com/term/infrastructure/known-hosts
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
