最近項目組的源碼倉庫遷移。本着「偷懶」的精神,兩個倉庫我用了一個ssh的pubkey,在新倉庫中使用tortoiseGit來clone、pull、push代碼沒有問題。可是,想使用vscode的git拓展的時候報錯「Git: host key verification failed」。git
這個問題我在網上搜索了兩三個小時,發現緣由是~/.ssh/known_hosts
文件中沒有新倉庫的配置。bash
[xx.xxx.com]:22,[192.168.0.18]:22 ssh-rsa AAAAB3NzaCAQABAAABAQCTJaeyAMkqozFQqaYhD4iC2XUq9G9jbWUQUcYDfEoLhBOoNTFTjn6uSwHYo7I6QlbFyCxaUqPvbdD2v1v34v4sy+r+M0LAyzaSV5u8rDf45yHK1H8T+PSfoq1FxzdhqmFIarAIneLSYlyit/nqiTI6jSHVKdUAMaOjKPCiMHddubDLYfvf0sF29tNthhzFMTDNX9qy5WvkDGHn5FNUwkFPJLbIJ+xuBJfgmvf+HhDvwVyo45Ip9kiz+Uv/2HtAavHRaJnYMERVHCsGW5gkSmOZ44BVv+OK+zrIqjQik72Umu5xX/wMDkKO6+i1SJYGA+94kw232xY5DNCrhgYVxifP
複製代碼
因而我複製了老倉庫的配置,修改前邊的ip參數。ssh
[xx.xxx.com]:22,[192.168.0.18]:22 ssh-rsa AAAAB3NzaCAQABAAABAQCTJaeyAMkqozFQqaYhD4iC2XUq9G9jbWUQUcYDfEoLhBOoNTFTjn6uSwHYo7I6QlbFyCxaUqPvbdD2v1v34v4sy+r+M0LAyzaSV5u8rDf45yHK1H8T+PSfoq1FxzdhqmFIarAIneLSYlyit/nqiTI6jSHVKdUAMaOjKPCiMHddubDLYfvf0sF29tNthhzFMTDNX9qy5WvkDGHn5FNUwkFPJLbIJ+xuBJfgmvf+HhDvwVyo45Ip9kiz+Uv/2HtAavHRaJnYMERVHCsGW5gkSmOZ44BVv+OK+zrIqjQik72Umu5xX/wMDkKO6+i1SJYGA+94kw232xY5DNCrhgYVxifP
[xx.xxx.com]:22,[192.168.0.19]:22 ssh-rsa AAAAB3NzaCAQABAAABAQCTJaeyAMkqozFQqaYhD4iC2XUq9G9jbWUQUcYDfEoLhBOoNTFTjn6uSwHYo7I6QlbFyCxaUqPvbdD2v1v34v4sy+r+M0LAyzaSV5u8rDf45yHK1H8T+PSfoq1FxzdhqmFIarAIneLSYlyit/nqiTI6jSHVKdUAMaOjKPCiMHddubDLYfvf0sF29tNthhzFMTDNX9qy5WvkDGHn5FNUwkFPJLbIJ+xuBJfgmvf+HhDvwVyo45Ip9kiz+Uv/2HtAavHRaJnYMERVHCsGW5gkSmOZ44BVv+OK+zrIqjQik72Umu5xX/wMDkKO6+i1SJYGA+94kw232xY5DNCrhgYVxifP
複製代碼
作驗證,發現仍是不行。工具
再去搜索問題,終於找到解決方法,參考連接。ui
該方法使用的是GitGui來自動添加倉庫的known_hosts配置,具體步驟以下:spa
至此已經完成了新倉庫known_hosts的配置添加,可在~/.ssh/known_hosts
文件中查看。code
若是代碼尚未克隆下來,也能夠直接使用GitBah,能夠達到一樣的效果,一樣參看參考連接。ip