title: gitlab 配置ssh key后不生效问题
tag: [Sdudoc, git, gitlab, ssh, ssh key]
category: 技术


描述

由于项目更换了远程仓库,从github迁移至gitlab,笔者于是新建了一个ssh key专门用于gitlab的认证,但是使用时却发现ssh key并没有生效。

笔者认为必须要搞清楚ssh认证期间发生了什么。

先尝试执行:

ssh -vvvT git@gitlab.swsdu.online

完整的DEBUG信息在附录中,这里截取一条重要信息:

debug1: Offering public key: /c/Users/11049/.ssh/id_rsa …

可以看到,认证时并没有用笔者新生成的sdudoc_gitlab密钥,而是之前的id_rsa

那么解决方法也就很明确了。

解决方法

在 ~/.ssh/ 下建立一个config文件,没有后缀,如果有的话直接进去修改

Host git.swsdu.onlineHostName git.swsdu.onlineIdentityFile ~/.ssh/sdudoc_gitlabPreferredAuthentications publickey----
Host [ip 或 域名]HostName [ip 或 域名]IdentityFile ~/.ssh/[key name]PreferredAuthentications publickey

再次测试,通过

附录

失效时的DEBUG日志

debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving “git.swsdu.online” port 22
debug2: ssh_connect_direct
debug1: Connecting to git.swsdu.online [121.250.213.219] port 22.
debug1: Connection established.
debug1: identity file /c/Users/11049/.ssh/id_rsa type 0
debug1: identity file /c/Users/11049/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_dsa type -1
debug1: identity file /c/Users/11049/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/11049/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/11049/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/11049/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/11049/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/11049/.ssh/id_xmss type -1
debug1: identity file /c/Users/11049/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to git.swsdu.online:22 as ‘git’
debug3: hostkeys_foreach: reading file “/c/Users/11049/.ssh/known_hosts”
debug3: record_hostkey: found key type ECDSA in file /c/Users/11049/.ssh/known_hosts:8
debug3: load_hostkeys: loaded 1 keys from git.swsdu.online
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:9ZgxICswo+e0UCYxwRpzi8MQFOXECeUn9tP23hxVztA
debug3: hostkeys_foreach: reading file “/c/Users/11049/.ssh/known_hosts”
debug3: record_hostkey: found key type ECDSA in file /c/Users/11049/.ssh/known_hosts:8
debug3: load_hostkeys: loaded 1 keys from git.swsdu.online
debug3: hostkeys_foreach: reading file “/c/Users/11049/.ssh/known_hosts”
debug3: record_hostkey: found key type ECDSA in file /c/Users/11049/.ssh/known_hosts:8
debug3: load_hostkeys: loaded 1 keys from 121.250.213.219
debug1: Host ‘git.swsdu.online’ is known and matches the ECDSA host key.
debug1: Found key in /c/Users/11049/.ssh/known_hosts:8
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/11049/.ssh/id_rsa RSA SHA256:SXiMdbzwJse2yjl/7B2Sy+004be3e8TLrRLxVjqY3pA
debug1: Will attempt key: /c/Users/11049/.ssh/id_dsa
debug1: Will attempt key: /c/Users/11049/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/11049/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/11049/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/11049/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/11049/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/11049/.ssh/id_rsa RSA SHA256:SXiMdbzwJse2yjl/7B2Sy+004be3e8TLrRLxVjqY3pA
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /c/Users/11049/.ssh/id_dsa
debug3: no such identity: /c/Users/11049/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /c/Users/11049/.ssh/id_ecdsa
debug3: no such identity: /c/Users/11049/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /c/Users/11049/.ssh/id_ecdsa_sk
debug3: no such identity: /c/Users/11049/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /c/Users/11049/.ssh/id_ed25519
debug3: no such identity: /c/Users/11049/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /c/Users/11049/.ssh/id_ed25519_sk
debug3: no such identity: /c/Users/11049/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /c/Users/11049/.ssh/id_xmss
debug3: no such identity: /c/Users/11049/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

项目实训 : gitlab 配置ssh key后不生效问题相关推荐

  1. 【转】GitLab配合小乌龟配置SSH Key

    使用小乌龟拉取gitlab上的代码,还需要配置一下在小乌龟和gitlab上配置公钥和私钥.网上找了个教程,需要注意的是在使用puttygen.exe生成密钥对的时候要不停的动鼠标,,,不动鼠标的话进度 ...

  2. linux 系统网络服务器组建,配置和管理实训教程 pdf,Linux网络服务器配置管理项目实训教程2...

    Linux网络服务器配置管理项目实训教程2 附录2 Linux常用命令 在文本模式和终端模式下,经常使用Linux命令来查看系统的状态和监视系统的操作,如对文件和目录进行浏览.操作等.在Linux较早 ...

  3. 【项目实训】七牛云测试域名过期后所能采用的方法

    (第四周)文章一 背景 项目实训的图床是使用七牛云搭建的,但是目前还未验收其测试域名就将要过期,需要找到合适的方法来补救 方法 方法一:新建一个新的仓库 目前新建一个新的存储是不需要资金的,新建存储的 ...

  4. 【项目实训】0507公共周报(附数据库连接与操作说明文档)

    0514项目实训公共周报(附数据库连接与操作说明文档) 前端 1.layout页面做了重定向,修改命名: 2.添加了头像部分: 3.对前端界面进行了优化,更加美观: 4.探索了前端采用JavaScri ...

  5. 项目实训第一周(车道线检测)

    项目实训我主要负责计算机视觉方面,识别出车道线并据此导航.相关内容也更新在我的个人博客上个人网站 相关介绍 车道线检测如果用传统方法,识别速度较慢,效果不够好,容易受到多种因素的干扰,因此我们打算开发 ...

  6. 【项目实训】基于人脸识别的课堂签到管理系统(python+qt5+sqlite3+百度智能云)

    [项目实训]基于人脸识别的课堂签到管理系统(python+qt5+sqlite3+百度智能云) 一.环境介绍 二.签到功能 2.1 启动签到 2.2 结束签到 三.用户组操作 3.1 添加用户组 3. ...

  7. Github配置ssh key【不用密码访问Github上代码】

    文章目录 前言 配置SSH 第一步:检查本地主机是否已经存在ssh key 第二步:生成ssh key 第三步:获取ssh key公钥内容(id_rsa.pub) 第四步:Github账号上添加公钥 ...

  8. 2021年山东大学软件学院项目实训记录(第一周)

    这次项目实训中,我们小组选择的题目是在线考试系统,经过讨论分工,我负责考试管理部分中的前端开发部分. 首先进行环境配置. 前端开发最为便利的开发工具为VScode,我们选择的开发框架是Vue. VSc ...

  9. 项目实训(校园互助平台)

    项目实训 前言 一.开题答辩(3月11号) 二.准备阶段 1.任务分配(3月12日) 2.购买服务器,搭建服务器(3月13日) 3.购买域名,申请备案(3月15日-3月20日) 4.域名备案成功,添加 ...

  10. “中软综合项目实训”——把学生当员工培养

    "中软综合项目实训"--把学生当员工培养 中软卓越大连ETC 2013年,对于中国IT职业教育界而言,一场教育模式变革的旋风已经悄然刮起. 在市场经济日益成熟的今天,"人 ...

最新文章

  1. linux安装R包的安装
  2. asp.net panel 加html,ASP.NET 页面中动态增加的控件、添加事件
  3. java安全编码指南之:文件和共享目录的安全性
  4. 联想陈旭东:我们有工匠精神
  5. e-HR推动知识型企业人力资源管理提升
  6. 计算机命令提示符的使用,命令提示符(电脑系统命令提示符的打开方法)
  7. 快用苹果助手安装失败_穿越火线辅助腾讯手游助手常见问题汇总
  8. 点击给导航条加背景颜色
  9. 官方:长城保护坚持不改变原状、最低干预原则
  10. iMazing怎么恢复备份?iMazing恢复备份教程分享
  11. C++简介 C语言编程原理
  12. 『关键词挖掘』结合 LDA + Word2Vec + TextRank 实现关键词的挖掘
  13. pve万兆网卡驱动_PVE+lede+DSM网卡硬盘直通+win10
  14. dedecms织梦后台登录一直提示验证码错误
  15. SQL Compliance Manager Crack
  16. 写给20年后的自己:免费的午餐最贵
  17. Kubernetes HPA管理
  18. 用户画像,知乎Live总结
  19. 计算机网络工程专业毕业论文,网络工程参考文献
  20. 信息管理导论 | 信息资源人文管理

热门文章

  1. 富文本编辑器CKEditor配置与使用
  2. 什么是搜索引擎?有什么作用?
  3. python天眼查爬虫_学习Python3 天眼查 爬虫
  4. 罗永浩怒怼新浪科技,或将起诉
  5. iOS系统开发入门至精通学习指南
  6. div网页布局(做一个简单网页界面为例)
  7. http错误404.3解决办法
  8. IT互联网的一些职位的简称
  9. html设置请求头host,Http请求头Host字段作用
  10. 计算机在学前教育中作用论文,学前教育论文