栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

git ssh 免密登录 配置教程 【no matching host key type found】

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

git ssh 免密登录 配置教程 【no matching host key type found】

缘起和

1、给新手配置GIT SSH免密登录时,出现了登录问题,百思不得解。
2、为从原理上解决各种登录问题,特撰此文以开局,希望网友不吝提出各种问题。

常见问题 收集中

1、ssh登录时的 "Unable to negotiate with "或 ”no matching host key type found“错误。 [错误原因见下文](#1)

安装git,生成证书

1、从网上下载git for windows 并安装
2、进入Git bash, 执行 ssh-keygen -t rsa -C ‘ppp@happyever.com.cn’ 命令,生成密钥对并拷贝至"~/.ssh"目录下。
3、上传公钥文件至服务器端,并将其内容追加至 ~/.ssh/authorized_keys文件中。
具体参考实践:打开文件浏览器,选中任何目录鼠标右键进入Git Bash

 ssh-keygen -t rsa -C 'ppp@happyever.com.cn'
身份标识与.gitconfig文件

方法:在家目录(HOMEPATH)里创建 .gitconfig文件,文件格式举例如下:

[user]
    name = ppp
    email = ppp@happyever.com.cn

具体参考实践:鼠标右键进入Git Bash,然后

 cd ~
 pwd
 touch .gitconfig  
 vi .gitconfig 
 git config user.name  #查看配置是否生效
 git config user.email
ssh证书免密登录 客户端配置

方法:进入~下的.ssh子目录, 编辑(如果没有就创建)config文件,文件格式举例如下

#该文件用于配置公私钥对应的服务器
Host happyever
	HostName happyever.com.cn
	Port 4245
	User git
	IdentityFile ~/.ssh/id_rsa
    
#OpenSSH 8.8后的版本默认不支持ssh-dss和ssh-rsa算法(因其加密强度低),解决方法:加上如下2行 # OpenSSH 8.8 之前的版本不能有下面2行 (ssh -V 命令可查询OpenSSH版本) HostKeyAlgorithms +ssh-dss PubkeyAcceptedAlgorithms +ssh-rsa
Host gitee HostName gitee.com User git IdentityFile ~/.ssh/gitee_rsa # OpenSSH 8.8后的版本默认不支持ssh-dss和ssh-rsa算法,解决方法之一就是加上如下2行 # OpenSSH 8.8 之前的版本不能有下面2行 HostKeyAlgorithms +ssh-dss PubkeyAcceptedAlgorithms +ssh-rsa

具体参考实践:鼠标右键进入Git Bash,然后

 cd ~
 cd .ssh
 cat config
ssh证书免密登录 git验证

具体参考实践:鼠标右键进入Git Bash,然后

  git clone ssh://happyever/~/Projects/cfms.git
ssh证书免密登录 问题排查

如果不能实现证书免密,可在客户端进行问题排查, 排查目的:
 1、~/.ssh/config的配置是否正确
 2、ssh客户端是否使用的是该配置文件

  ssh -v happyever #如果没问题会自动登陆
  ssh -i ~/.ssh/id_rsa git@happyever.com.cn -p 4245

服务器端问题排查:

   su - 
   service sshd stop   
   #debug方式运行sshd守候进程..ssh客户端连接时观察其反应
   /usr/sbin/sshd -d  
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/388595.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号