用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通了
发表评论