【问题标题】:Git asking for password even after Public key is supplied即使提供了公钥,Git 也会要求输入密码
【发布时间】:2016-02-15 00:03:23
【问题描述】:

我一直在尝试将我的项目推送到 git,但即使我在 git UI 的配置文件部分下为 SSH 密钥提供了公钥,它仍然要求我输入密码。我已按照 git 提供的步骤创建并将 SSH 密钥添加到 UI 中的 NEW KEY 选项。我已经尝试了 2 天,但仍然无法修复它。我删除了所有过去的修改并将新的 git 安装到我的 Windows 10 并从头开始尝试但问题仍然存在。 使用

创建密钥
 ssh-keygen -t rsa -C "useri@company.com"

通过复制密钥将密钥添加到 GIT UI

clip < ~/.ssh/id_rsa.pub

当我尝试 SSH 到 git 时,我得到了

OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to git.company.com [198.41.85.18] port 22.
debug1: Connection established.
debug1: identity file /c/usernames/username/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/usernames/username/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to git.company.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64@openssh.com none
debug1: kex: client->server aes128-ctr umac-64@openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:GeFkVDzGN7W8Ngp/osU5gqDL5jdf6GDgF8lLPWapDU8
The authenticity of host 'git.company.com (198.41.85.18)' can't be established.
RSA key fingerprint is SHA256:GeFkVDzGN7W8Ngp/osU5gqDL5jdf6GDgF8lLPWapDU8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.company.com,198.41.85.18' (RSA) to the list of known hosts.
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
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: publickey
debug1: Offering RSA public key: /c/usernames/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /c/usernames/username/.ssh/id_dsa
debug1: Trying private key: /c/usernames/username/.ssh/id_ecdsa
debug1: Trying private key: /c/usernames/username/.ssh/id_ed25519
debug1: Next authentication method: password
git@git.company.com's password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
git@git.company.com's password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
git@git.company.com's password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

即使我尝试运行 ssh -T git@git.company.com

The authenticity of host 'git.company.com (198.41.85.18)' can't be established.
RSA key fingerprint is SHA256:GeFkVDzGN7W8Ngp/osU5gqDL5jdf6GDgF8lLPWapDU8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.company.com,198.41.85.18' (RSA) to the list of known hosts.
git@git.company.com's password:

来自 etc/ssh 的我的 ssh_conf 文件

#$OpenBSD: ssh_config,v 1.28 2013/09/16 11:35:43 sthen Exp $
# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h

我们将不胜感激。

【问题讨论】:

标签: git github ssh


【解决方案1】:

设置您的密钥(几个选项:)

创建 SSH 配置文件

您可以使用许多参数和不同的方法来构建 SSH 配置文件。

此示例中使用的别名条目的格式为:

Host alias 
  HostName bitbucket.org 
  IdentityFile ~/.ssh/identity

要为两个身份(workid 和 personalid)创建配置文件,您需要执行以下操作:

Open a terminal window.
Edit the ~/.ssh/config file. 

如果您没有配置文件,请创建一个。
为每个身份组合添加别名,例如:

Host workid
HostName bitbucket.org
IdentityFile ~/.ssh/workid

Host personalid
HostName bitbucket.org
IdentityFile ~/.ssh/personalid

将您的密钥添加到您的 github 帐户。

  • 登录github账号
  • 点击右上角的牧场主(设置)
  • 点击SSH keys
  • 点击Add ssh key
  • 粘贴您的密钥并保存

【讨论】:

  • 好的。我会试试的,我会尽快回来
猜你喜欢
  • 2018-04-19
  • 2012-01-25
  • 1970-01-01
  • 2020-07-21
  • 2015-07-28
  • 1970-01-01
  • 1970-01-01
  • 2022-01-06
  • 1970-01-01
相关资源
最近更新 更多