【发布时间】: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
我们将不胜感激。
【问题讨论】:
-
我在本地机器上生成的
-
显然服务器不接受您的密钥。既然您没有提及,那么密钥是否完全在服务器上授权?
.ssh/authorized_keys也可能有拼写错误(在服务器上;可能某些编辑器插入了换行符或其他内容)或.ssh目录可能有不正确的权限(它必须 not 可写组或其他人)。