ssh: id_rsa काम नहीं करता है, लेकिन अगर मैं इसका नाम बदलूं, तो यह काम करता है


10

मेरे पास अपने ~ / .shsh फ़ोल्डर में यह id_rsa है। लेकिन यह सिर्फ प्रमाणित नहीं करता है। अगर मैं इसे कॉपी करता हूं और इसे कुछ भी नाम नहीं देता, तो यह काम नहीं करता।

[qfan@mycomputer .ssh]$ ls -al id_rsa id_rsa_good
-rw------- 1 qfan qfan 1766 Dec  3 18:35 id_rsa
-rw------- 1 qfan qfan 1766 Nov 20 19:43 id_rsa_good
[qfan@mycomputer .ssh]$ sha1sum id_rsa id_rsa_good
8cc7f68170038b184bba0541be7d105bb36f7d11  id_rsa
8cc7f68170038b184bba0541be7d105bb36f7d11  id_rsa_good
[qfan@mycomputer .ssh]$ ssh localhost -i id_rsa
qfan@localhost's password: 

[qfan@mycomputer .ssh]$ ssh localhost -i id_rsa_good
Enter passphrase for key 'id_rsa_good': 
Last login: Tue Dec  3 18:46:46 2013 from 127.0.0.1
[qfan@mycomputer ~]$ exit
logout
Connection to localhost closed.

ध्यान दें कि "ssh localhost -i id_rsa" विफल हो जाता है और ssh नियमित पासवर्ड लॉगिन के लिए पूछना शुरू कर देता है।

मैंने -vvv का उपयोग किया और यहां लॉग्स का अंतर है:

[qfan@mycomputer .ssh]$ ssh localhost -i id_rsa_good -vvv 2> log1_good.txt
Enter passphrase for key 'id_rsa_good': 

[qfan@mycomputer .ssh]$ ssh localhost -i id_rsa -vvv 2> log2_bad.txt
qfan@localhost's password: 

[qfan@mycomputer .ssh]$ diff log1_good.txt log2_bad.txt 
7c7
< debug3: Not a RSA1 key file id_rsa_good.
---
> debug3: Not a RSA1 key file id_rsa.
41c41
< debug1: identity file id_rsa_good type -1
---
> debug1: identity file id_rsa type 1
81,82c81,82
< debug2: dh_gen_key: priv key bits set: 126/256
< debug2: bits set: 533/1024
---
> debug2: dh_gen_key: priv key bits set: 127/256
> debug2: bits set: 503/1024
90c90
< debug2: bits set: 506/1024
---
> debug2: bits set: 539/1024
103c103
< debug2: key: id_rsa_good ((nil))
---
> debug2: key: id_rsa (0x7f953ea96f90)
136,138c136,145
< debug1: Trying private key: id_rsa_good
< debug1: PEM_read_PrivateKey failed
< debug1: read PEM private key done: type <unknown>
---
> debug1: Offering public key: id_rsa
> debug3: send_pubkey_test
> debug2: we sent a publickey packet, wait for reply
> debug3: Wrote 368 bytes for a total of 1477
> debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
> 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
[qfan@mycomputer .ssh]$ 

मैंने कुंजी फ़ाइल से पासफ़्रेज़ को निकालने का भी प्रयास किया, लेकिन यह अभी भी काम नहीं करता है अगर id_rsa नाम दिया गया है।

तो, वहाँ क्या गलत हो गया?

------- संपादित करें -------

[qfan@mycomputer .ssh]$ file id_rsa
id_rsa: ASCII text
[qfan@mycomputer .ssh]$ cat id_rsa |head -n2
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED

1
क्या आप सुनिश्चित हैं कि फ़ाइल में RSA कुंजी है? यह इस तरह दिखता है जब इसे id_rsa ssh नाम दिया जाता है, यह मानता है कि यह एक rsa कुंजी (टाइप 1) है, लेकिन जब आप इसे id_rsa_good का नाम देते हैं तो यह निश्चित नहीं होता है (टाइप -1)।
— mfarver

1
क्या आप चल सकते हैं file id_rsaऔर हमें आउटपुट देख सकते हैं ? यदि यह कुछ बहुत पसंद नहीं है id_rsa: PEM RSA private key, तो mfarver में अच्छी तरह से एक बिंदु हो सकता है!
— मध्याह्न

यह टेक्स्ट फ़ाइल है: [qfan @ mycomputer .ssh] $ फ़ाइल id_rsa id_rsa: ASCII टेक्स्ट [qfan @ mycomputer .ssh] $ cat id_rsa | head -n2 ----- BEGIN RSA PRIVATE KEY ----- प्रोक-प्रकार: 4, विस्तारित
— क्यूई फैन

जवाबों:


12

कारण मिल गया। id_rsa.pubएक ही .sshफ़ोल्डर में मेरी फ़ाइल एक सार्वजनिक कुंजी है जो एक अलग पहचान फ़ाइल से संबंधित है। जब id_rsa.pubयह मेल नहीं खाता है तो id_rsa,यह स्वचालित रूप से विफल हो जाता है। id_rsa.pubफ़ाइल को निकालना या स्थानांतरित करना id_rsaकाम करता है।


1
मुझे यह समझने में अच्छा लगेगा कि ऐसा क्यों है ...
— डेविड रेस्निक

2
@DavidResnick मैंने उस सवाल का जवाब serverfault.com/a/587560/214507 में दिया
— kasperd
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.