即使提供了公钥,Git也会要求输入密码

时间:2016-02-10 07:03:07

标签: git github ssh

我一直试图将我的项目推向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

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

设置密钥(几个选项:)

创建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帐户
  • 点击右上角的牧场主(设置)
    github account settigns
  • 点击SSH keys
    ssh key section
  • 点击Add ssh key
    Add ssh key
  • 粘贴您的密钥并保存