用gitblit添加新仓库
touch README.md git init git add README.md git commit -m "first commit" git remote add origin ssh://username@172.16.1.203:29418/xxxxxxx.git git push -u origin master
报错一
Unable to negotiate with 172.16.1.203 port 29418: no matching host key type found. Their offer: ssh-rsa,ssh-dssfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
解决方法:
生成ssh密钥
命令行
git config --global user.name "username"
git config --global user.email "mail@gmail.com"
ssh-keygen -t rsa -C "配置的邮箱"
提示输入全留空,直接一路回车
生成的key在 ~/.ssh/id_rsa 和id_rsa.pub
~ 表示当前用户,windows在C:\用户\yourname,linux/Mac 即当前用户home目录
2. 将 id_rsa.pub公钥添加到gitblit上去,gitlab同理
3. 上面的报错信息是说你的 SSH 客户端和服务器之间的密钥类型不匹配,并且提示了 Their offer 的类型,由于上面我们创建了rsa密钥,所以在~/.ssh/config 文件中添加以下内容,没有文件自己创建
Host 172.16.1.203 HostKeyAlgorithms +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
再运行git fetch命令会提示将主机添加到known_hosts,直接回车即可,git通了
报错二
补充,今天添加一个新仓库又出幺蛾子了。按上述步骤,命令行推拉代码都没问题, SourceTree 不行
报错
The server's host key is not cached in the registry. Youhave no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:ssh-rsa 2048 **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**If you trust this host, enter "y" to add the key toPuTTY's cache and carry on connecting.If you want to carry on connecting just once, without
adding the key to the cache, enter "n".If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)
没地方按y
按网友教程
在SourceTree安装目录下找到PuTTy工具plink.exe,C:\.........\SourceTree\app-3.4.19\tools\putty,运行命令 plink.exe root@172.16.1.203 -P 端口号,按y。然并卵。
在这个步骤卡住,密码怎么输入都不对
-- Keyboard-interactive authentication prompts from server: ------------------
| Password authentication
| Password:
解决方法:
发表评论