A blog probably of interest only to nerds by John Morton.

09Aug2017

How to re-add Github key to a server

Note to self: Don’t erase your knownhosts file. (head­slap!)

I pro­vi­sion servers with Lar­avel Forge and messed up my deploy­ment from Github recent­ly. I was mess­ing around in the .ssh fold­er on my serv­er and delet­ed the known_hosts file. 

The next time I tried to deploy my code base from Github though, I got the fol­low­ing error.

Host key verification failed.
fatal: Could not read from remote repository.

I need­ed to get my serv­er to rec­og­nize” Github as a known host again and wasn’t sure how to do that. Google point­ed me to this solu­tion on StackExchange.

After log­ging into my remote serv­er via SSH, this com­mand got Github safe­ly back into my known hosts.

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts