dotnet core 加入小组

394个成员 38个话题 创建时间:2017-09-10

Gitlab设置SSH调试连接提示需要输入密码并报错 Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

发表于03-19 295次查看

环境:CentOS 7.2

前置条件:本地无SSH密钥对

操作:按照本地部署Gitlab上的站点下的/help/ssh/README,首先生成一个新的SSH密钥对

第一步:ssh-keygen -t rsa -C "your.email@example.com" -b 4096(剩下的一路Enter执行)
第二步:Copy公钥复制到Gitlab SSH秘钥中

此时查看所有秘钥信息:

ls -al ~/.ssh
显示如下结果:
total 20
drwx------  2 root root 4096 Mar 19 16:51 .
dr-xr-x---. 6 root root 4096 Mar 19 16:53 ..
-rw-------  1 root root    0 Mar 18 16:13 authorized_keys
-rw-------  1 root root 3243 Mar 19 16:47 id_rsa
-rw-r--r--  1 root root  740 Mar 19 16:47 id_rsa.pub
-rw-r--r--  1 root root  171 Mar 19 12:45 known_hosts

结果在 git push -u origin master 命令时提示输入密码,并且出现标题所示错误

尝试通过运行来调试连接ssh -Tv git@example.com,出现如下信息

[root@VM_0_13_centos ~]# ssh -Tv git@localhost
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 22:49:b2:5c:7c:8f:73:56:89:29:8a:bd:56:49:74:66
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
git@localhost's password:

该问题不知道如何解决,请问有出现类似问题,并且成功解决的方案吗?

 

 

 

 

4回复
  • 2楼 依然无辰 03-19

    尝试了下将私钥加入到本地计算机的ssh-agent中,问题也还是不能解决

    加入本地ssh-agent中:
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
    查看当前计算机中存储的秘钥:ssh-add -l 
    再次检测本地计算机与gitlab的连接状态:ssh -T git@localhost

     

  • 3楼 薛家明 03-20

    解决了吗我也是这个问题

  • 4楼 薛家明 03-20

    https://mp.weixin.qq.com/s?__biz=MzI1MTA0OTM0Mw==&mid=2650959269&idx=1&sn=9200a125a392ab758e5eda70cb06f697&chksm=f20e29b5c579a0a3e6dc7f45e4e6687ad2711df9625ba5d0bedfa5f462730c822e716618600e&mpshare=1&scene=1&srcid=08179qwIdJzHhlvrkJRbWonQ&key=3ca3acd7b7e79486ba072b984547bfaa48440387c4a04b42aceb4989f2dfd1e14e5b06a7cb48de54a8593d5f366c554f4396c09ac920fbeaf7df045569c0ea6eaa6395c0839b0902833a950a6a2f9725&ascene=0&uin=MjE4MTczNDcwMA%3D%3D&devicetype=iMac+MacBookAir6%2C1+OSX+OSX+10.12.5+build(16F73)&version=12020

     

    这篇文章希望对你有帮助,进入config后vi gitlab.rb 找到端口改掉,并且把前面的#号去掉不然是注释的不起作用

  • 5楼 依然无辰 03-21

    参考地址:5分钟快速用Docker部署你自己的GitLab

    前提是在创建容器时,使用了其它端口10022(非22)映射容器内部SSH端口

    解决方法:

    第一步:ssh -p 10022 git@localhost(指定端口进行连接)

    第二步:vi srv/gitlab/config/gitlab.rb (修改配置信息)

     #  gitlab_rails['gitlab_shell_ssh_port'] = 22
    (上述大概在60几行)修改成如下
    gitlab_rails['gitlab_shell_ssh_port'] = 10022

    第三步:重启容器。

     

发表回复
你还没有登录,请先 登录或 注册!