An SSH key on its own works from anywhere in the world. That’s handy, until someone copies it. For keys that only ever log in from home, I like to tell the server exactly that, and it takes one option in front of the key.
from="192.168.1.0/24" ssh-ed25519 AAAAC3Nza... laptop
Put the option at the start of the key’s line in ~/.ssh/authorized_keys on the server. sshd then wants two things: the right key, and a client address that matches the list. CIDR ranges like the one above work, and so do wildcards and comma-separated lists such as from="192.168.1.*,10.0.0.5". An entry with a ! in front excludes an address. The man page puts the point well: a stolen key alone is no longer enough, the attacker would also have to get into your network.
It combines nicely with restrict for a key that runs a backup job from one fixed machine:
from="192.168.1.20",restrict ssh-ed25519 AAAAC3Nza... backup-job
restrict turns off port, agent and X11 forwarding and the terminal, which a backup with rsync or borg doesn’t need anyway.
Some caveats before you lock yourself out. Use IP addresses, not host names: UseDNS is off by default in sshd, and then only addresses work in from=. If you also reach the server over a VPN such as Tailscale, the connection comes from the VPN address (a 100.x address on Tailscale), not from your LAN, so add that range or the key stops working on the road. And a list with only negated entries never matches anything, so always include at least one positive pattern. Keep a second SSH session open while you edit the file, and test from a new one.
Further reading: sshd(8) manual: authorized_keys file format, ssh_config(5) manual: patterns