我已将克隆到本地文件夹(位于Windows 7 PC上)我的网站(托管在CentOS 7服务器上)的git存储库中。我想要使用git命令,如git pull
,而不必每次输入用户的密码。Git调用SSH与不工作的密钥
>git remote -v
origin ssh://[email protected]:1234/home/mylinuxuser/domains/mydomain/public_html/ (fetch)
origin ssh://[email protected]:1234/home/mylinuxuser/domains/mydomain/public_html/ (push)
我已经创建了一个密钥对。该id_rsa
文件是C:\Users\mywindowsuser\.ssh
和id_rsa.pub
我已经发送到服务器,并添加到authorized_keys
文件:
cat id_rsa.pub >> authorized_keys
的authorized_keys
文件由mylinuxuser
拥有和访问权限是600
。 .ssh
文件夹的访问权限为700
。
在我的本地机器上,我曾与
Host *
IdentityFile ~/.ssh/id_rsa
我试图在Linux服务器上重新启动SSH service sshd restart
作为su
以及充满config
文件中.ssh
文件夹中。没有帮助。
还增加id_rsa
到许多路径,因为Ifound一些答案领先的堆栈是这样的:这些工作
C:\Program Files\Git\.ssh
C:\Program Files (x86)\Git\.ssh
C:\Users\mywindowsuser\AppData\Local\VirtualStore\Program Files\Git\.ssh
C:\Users\mywindowsuser\AppData\Local\VirtualStore\Program Files (x86)\Git\.ssh
无。我想知道是否有其他文件存在干扰。例如,我在C:\Users\mywindowsuser\.ssh
中有environment
文件和known_hosts
文件,但我怀疑它。
不过,任何时候我尝试打电话git pull
它要求mylinuxuser
密码...
任何帮助,将不胜感激!
[编辑]在评论中建议的结果:
ssh -v -p1234 [email protected]
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /c/Users/mywindowsuser/.ssh/config
debug1: /c/Users/mywindowsuser/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 1.2.3.4 [1.2.3.4] port 1234.
debug1: Connection established.
debug1: identity file /c/Users/mywindowsuser/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mywindowsuser/.ssh/id_rsa-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_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 1.2.3.4:1234 as 'mylinuxuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] 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:verylongkey
debug1: Host '[1.2.3.4]:1234' is known and matches the RSA host key.
debug1: Found key in /c/Users/mywindowsuser/.ssh/known_hosts:1
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,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/mywindowsuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
我假设你向git-hub帐户添加了公共ssh密钥,但你可能需要将你的新私钥添加到ssh-agent。试试'ssh-add〜/ .ssh/id_rsa'。确保'ssh-agent'正在运行。 – jiveturkey
这不是一个github帐户,因为我说它是一个私人服务器。我做了你的建议 - 在普通的cmd中,它没有工作,但它在git bash中做了,并且我添加了标识:/c/Users/mywindowsuser/.ssh/id_rsa(/c/Users/mywindowsuser/.ssh/id_rsa )'作为答案...但是,当我尝试'git pull'时它仍然要求输入密码,所以它不起作用,很遗憾 –
尝试通过ssh以详细的方式登录进行调试。 'ssh -v -v -p 1234 mylinuxuser @ 1.2.3.4' – Schwern