2012-05-31 44 views
2

我在使用OpenSSH for Windows使用公鑰認證時遇到了問題。我已經生成密鑰對並將密鑰正確傳輸到遠程服務器,但是當我在Windows上使用ssh時,它會一直提示輸入密碼。我將相同的私鑰傳給了我的mac,並且出現了一個錯誤,即權限過於開放(644),並且會被忽略,除非設置爲600.「chmod 600 id_rsa」和繁榮,它工作。我似乎無法找出通過腳本在Windows上更改此方法的方法,但我無法使用gui進行此操作。OpenSSH公鑰與Cygwin不兼容

必須有一個簡單的方法來做到這一點嗎?有沒有一個內置的windows命令?即時通訊目前使用的是XP,但需要這也對Vista的工作,7

EDIT3:我報廢了FAT32支持和下載一個完整的cygwin的安裝只是爲了幫助診斷問題,並使用搭配chmod 600設置權限(其幸運地設置窗戶)。仍然是一個失敗。所以我猜這個問題不是權限,而是導致密鑰失敗的其他問題。

EDIT2: 我設法找到一個cacls命令可能會做什麼,我需要,但它只會在NTFS文件系統的工作顯然,我需要支持FAT32。

EDIT1:當我在3倍詳細模式運行OpenSSH中,我們這是我得到:

OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to SERVER.NAME.HERE.CA [134.153.48.1] port 22. 
debug1: Connection established. 
debug1: identity file /home/jtg733/.ssh/identity type -1 
debug3: Not a RSA1 key file /home/jtg733/.ssh/id_rsa. 
debug2: key_type_from_name: unknown key type '-----BEGIN' 
debug3: key_read: missing keytype 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug2: key_type_from_name: unknown key type '-----END' 
debug3: key_read: missing keytype 
debug1: identity file /home/jtg733/.ssh/id_rsa type 1 
debug1: identity file /home/jtg733/.ssh/id_dsa type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1-hpn13v11lpk 
debug1: match: OpenSSH_5.9p1-hpn13v11lpk pat OpenSSH* 
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 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman- group1-sha1 
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: none,zlib 
debug2: kex_parse_kexinit: none,zlib 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
debug2: kex_parse_kexinit: ssh-rsa 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour,aes192-cbc,aes256-cbc,aes128-ctr 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour,aes192-cbc,aes256-cbc,aes128-ctr 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: none,[email protected] 
debug2: kex_parse_kexinit: none,[email protected] 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_init: found hmac-md5 
debug1: kex: server->client aes128-cbc hmac-md5 none 
debug2: mac_init: found hmac-md5 
debug1: kex: client->server aes128-cbc hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug2: dh_gen_key: priv key bits set: 127/256 
debug2: bits set: 534/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug3: check_host_in_hostfile: filename /home/jtg733/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 2 
debug3: check_host_in_hostfile: filename /home/jtg733/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 3 
debug1: Host 'SERVER.NAME.HERE.CA' is known and matches the RSA host key. 
debug1: Found key in /home/jtg733/.ssh/known_hosts:2 
debug2: bits set: 522/1024 
debug1: ssh_rsa_verify: signature correct 
debug2: kex_derive_keys 
debug2: set_newkeys: mode 1 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug2: set_newkeys: mode 0 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug2: service_accept: ssh-userauth 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug2: key: /home/jtg733/.ssh/identity (0x0) 
debug2: key: /home/jtg733/.ssh/id_rsa (0x100e9cb8) 
debug2: key: /home/jtg733/.ssh/id_dsa (0x0) 
debug1: Authentications that can continue: publickey,password,hostbased 
debug3: start over, passed a different list publickey,password,hostbased 
debug3: preferred publickey,keyboard-interactive,password 
debug3: authmethod_lookup publickey 
debug3: remaining preferred: keyboard-interactive,password 
debug3: authmethod_is_enabled publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: /home/jtg733/.ssh/identity 
debug3: no such identity: /home/jtg733/.ssh/identity 
debug1: Offering public key: /home/jtg733/.ssh/id_rsa 
debug3: send_pubkey_test 
debug2: we sent a publickey packet, wait for reply 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Trying private key: /home/jtg733/.ssh/id_dsa 
debug3: no such identity: /home/jtg733/.ssh/id_dsa 
debug2: we did not send a packet, disable method 
debug3: authmethod_lookup password 
debug3: remaining preferred: ,password 
debug3: authmethod_is_enabled password 
debug1: Next authentication method: password 

所以它似乎拿到鑰匙,發送測試數據包,然後跳到右邊進入下一輪的認證。

回答

2

由於某些原因生成密鑰服務器端,然後使用scp將密鑰從服務器生成私鑰複製到窗口框中,然後使用cygwin chmod 600像魅力一樣工作。

我仍然不知道爲什麼服務器不接受Windows公鑰,但Windows會接受服務器的私鑰。好像電腦巫毒對我來說。

0

您應該可以通過win32security API以編程方式執行此操作,但我對ACL和Windows瞭解不夠,無法給您一個更完整的答案。

您也應該可以右鍵單擊文件,轉到安全性並將其設置在那裏。

但是你可能在Windows上有其他問題 - 我沒有使用OpenSSH足夠知道。