brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: IdentitiesOnly yes makes ssh use only the key you configured

Network and access
~/tips/tip-ssh-identitiesonly-config

IdentitiesOnly yes

Stops ssh from offering every key in the agent and sends only the identity file you named.

ssh likes to be helpful and will offer keys from your agent to a server. For the server on the other side, that looks like someone trying their luck.

The ssh_config man page says IdentitiesOnly makes ssh use only the configured authentication identity and certificate files, even if the agent offers more. The value is yes or no, and no is the default.

Host nas
    HostName 192.168.1.20
    User admin
    IdentityFile ~/.ssh/id_ed25519_nas
    IdentitiesOnly yes

Now ssh nas offers that key and nothing else from the agent. I like that a host I only half trust does not get to see the public key of every identity I own.

To see which identities ssh offers, add -v:

ssh -v nas

The debug output lists the keys it tries.

There is one trap. If the key lives only in the agent and you set no IdentityFile, IdentitiesOnly yes leaves ssh with nothing to offer, because only configured files count. In that case, point IdentityFile at the public key file. Also check that every host has an identity file before you put the option under Host *, or some logins will start failing.

Further reading: ssh_config(5)

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link