我已將克隆到本地文件夾(位於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