SSH keys and GitHub

Fix "Host key verification failed"

SSH doesn't know the server yet and can't ask you, often in scripts or CI. Add the server's key to known_hosts.

Fill these in once
  1. Add the server's key to known_hosts
    Terminal
    ssh-keyscan github.com >> ~/.ssh/known_hosts

    Or just connect once by hand and type yes.

  2. Try again
    Terminal
    ssh -T git@github.com

    Use your own server's ssh command if it isn't GitHub.

  1. Add the server's key to known_hosts
    Terminal · Ubuntu / Debian
    ssh-keyscan github.com >> ~/.ssh/known_hosts

    Or just connect once by hand and type yes.

  2. Try again
    Terminal · Ubuntu / Debian
    ssh -T git@github.com

    Use your own server's ssh command if it isn't GitHub.

  1. Add the server's key to known_hosts
    PowerShell
    ssh-keyscan github.com | Add-Content "$env:USERPROFILE\.ssh\known_hosts"

    Or just connect once by hand and type yes.

  2. Try again
    PowerShell
    ssh -T git@github.com

    Use your own server's ssh command if it isn't GitHub.