簡體   English   中英

使用Windows使用SSH連接到github

[英]Connect to github with ssh using windows

我目前正在嘗試使用ssh在Windows上使用git。 我生成了一個密鑰(使用ssh-keygen -t rsa),並將公共密鑰添加到了github。 不幸的是,每次我連接時,都會出現以下內容:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'C:\\Users\\DaGeRe\\.ssh\\id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: C:\\Users\\DaGeRe\\.ssh\\id_rsa
Enter passphrase for C:\Users\DaGeRe\.ssh\id_rsa:

因此,為使此工作正常進行,我完成了chmod 700(就像無休止的帖子中所建議的那樣,例如使用Git GUI或ssh-keygen的SSH私鑰權限太開放了 ),ls返回以下內容:

-rw-r--r--    1 DaGeRe   mkpasswd      951 May 20 10:59 id_rsa
-rw-r--r--    1 DaGeRe   mkpasswd      239 May 20 10:59 id_rsa.pub

但是不幸的是,ssh-add C:\\ Users \\ DaGeRe.ssh \\ id_rsa或ssh -T git@github.com仍然返回錯誤。 chmod命令似乎不起作用,甚至chmod -c 700 id_rsa(例如在這里說: https : //superuser.com/questions/397288/using-cygwin-in-windows-8-chmod-600-does-not-預期的效果 )沒有任何改變。

嘗試刪除Windows的所有權限(通過設置中的菜單)也無效。 在“屬性”->“安全性”(也由我翻譯自“ Eigenschaften-> Sicherheit”)中添加用戶“所有人”(德語:“ Jeder”后,該用戶在英語窗口中可能會被稱為“不同”),並拒絕他的任何訪問權限,警告消失。

有了第一個空密碼短語密鑰,下面的輸出來自ssh-add:

C:\Users\DaGeRe\.ssh>ssh-add id_rsa
Enter passphrase for id_rsa:

此后,什么也不顯示。 但是ssh-add -l也不會返回任何內容:

C:\Users\DaGeRe\.ssh>ssh-add -l
The agent has no identities.

如果添加密碼,它總是說密碼是錯誤的,具有錯誤的權限(因此出現從頭開始的消息)和具有正確的權限(因此不會出現錯誤,但仍然表示正確的短語是錯誤的)。

我正在Windows上使用OpenSSH 3.8.1,但沒有安裝cygwin。

因此,即使權利設置正確,似乎也不會添加它。 如果有人暗示如何解決此問題,我將非常高興。

這是ssh -vT git@github.com的輸出

OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004                               
debug1: Reading configuration data /cygdrive/c/Users/DaGeRe/.ssh/config   
debug1: Applying options for github.com                                   
debug1: Reading configuration data /etc/ssh_config                        
debug1: Connecting to github.com [192.30.252.130] port 22.                
debug1: Connection established.                                           
debug1: identity file "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa" type -1      
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0 
debug1: no match: libssh-0.6.0                                            
debug1: Enabling compatibility mode for protocol 2.0                      
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1                      
debug1: SSH2_MSG_KEXINIT sent                                             
debug1: SSH2_MSG_KEXINIT received                                         
debug1: kex: server->client aes128-cbc hmac-sha1 none                     
debug1: kex: client->server aes128-cbc hmac-sha1 none                     
debug1: sending SSH2_MSG_KEXDH_INIT                                       
debug1: expecting SSH2_MSG_KEXDH_REPLY                                    
debug1: Host 'github.com' is known and matches the RSA host key.          
debug1: Found key in /cygdrive/c/Users/DaGeRe/.ssh/known_hosts:1          
debug1: ssh_rsa_verify: signature correct                                 
debug1: SSH2_MSG_NEWKEYS sent                                             
debug1: expecting SSH2_MSG_NEWKEYS                                        
debug1: SSH2_MSG_NEWKEYS received                                         
debug1: SSH2_MSG_SERVICE_REQUEST sent                                     
debug1: SSH2_MSG_SERVICE_ACCEPT received                                  
debug1: Authentications that can continue: publickey                      
debug1: Next authentication method: publickey                             
debug1: Trying private key: "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa"        
debug1: No more authentication methods to try.                            
Permission denied (publickey).  

經過一番嘗試后,我發現了使用Windows並運行git的方法來解決該問題:使用Putty代替OpenSSH。

必須將GIT_SSH設置為Plink(在我的情況下為SET GIT_SSH = C:\\ PortablePrograme \\ putty \\ PLINK.EXE)並按以下說明啟動pagent: http ://guides.beanstalkapp.com/version-control/git-on- windows.html (如果已經有一個ssh-key,已經創建並添加到了github,則可以通過轉換將其轉換為putty格式,而不用創建新的密鑰)。

我想這只是解決問題的一種可能的方法,如果有人有其他解決方案,我將很高興聽到。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM