सार्वजनिक कुंजी प्रमाणीकरण विफल रहा


9

मैं ubuntu 13.10 का उपयोग कर रहा हूं, और सर्वर ubuntu 12.04 चलाता है। मैंने ssh-keygen का उपयोग करके निजी और सार्वजनिक कुंजी उत्पन्न की थी, और id_rsa.pub को सर्वर साइड में डाल दिया और इसे authorzied_keysइंटरनेट पर मिलने वाली विधि के अनुरूप जोड़ दिया । लेकिन, मुझे तब भी पासवर्ड डालना होगा जब मैं लॉगिन करने की कोशिश कर रहा हूं। मैं घर dir सेट करने के लिए 700 है, .sh dir 700 करने के लिए, 600 करने के लिए authorzied_keys फ़ाइल, और मैं checke sshd_config फ़ाइल है, और कुछ नहीं हुआ।

डीबग इन्फ़ोमेशन (-vvv विकल्प के साथ) और sshd_config निम्नानुसार है, और सर्वर के dif.log फ़ाइल में सूचीबद्ध कुछ भी नहीं है।

मैंने क्लाइंट और सर्वर साइड दोनों पर ओपनश-सर्वर ओपनश-क्लाइंट भी अपडेट किया है।

क्या मुझे कुछ और करना है? किसी भी जानकारी के लिए धन्यवाद।

debug3: load_hostkeys: loading entries for host "[xxx.101.15.62]:2222" from file "/home/leetom/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /home/leetom/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "[xxx.101.15.62]:2222" from file "/home/leetom/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /home/leetom/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys
debug1: Host '[xxx.101.15.62]:2222' is known and matches the ECDSA host key.
debug1: Found key in /home/leetom/.ssh/known_hosts:2
debug1: ssh_ecdsa_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: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/leetom/.ssh/id_rsa ((nil)),
debug2: key: /home/leetom/.ssh/id_dsa ((nil)),
debug2: key: /home/leetom/.ssh/id_ecdsa ((nil)),
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,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/leetom/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA 68:51:b6:ed:cc:c2:54:f4:xx:15:41:d7:f5:4a:0e:da
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/leetom/.ssh/id_dsa
debug3: no such identity: /home/leetom/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/leetom/.ssh/id_ecdsa
debug3: no such identity: /home/leetom/.ssh/id_ecdsa: No such file or directory
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
leetom@xxx.101.15.62's password: 

और sshd_config

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

जवाबों:


12

यह बिट ऐसा लगता है जैसे हमने क्रिप्टोग्राफ़िक लॉगिन का प्रयास करने के लिए आपकी निजी कुंजी का उपयोग किया था, फिर हमें दूसरों को आज़माना पड़ा क्योंकि यह स्वीकार नहीं किया गया था:

debug1: Trying private key: /home/leetom/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA 68:51:b6:ed:cc:c2:54:f4:xx:15:41:d7:f5:4a:0e:da
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password

सबसे आसान समस्या सार्वजनिक कुंजी पर आपकी प्रतिलिपि बनाने में हो सकती है, क्योंकि मुझे उसी प्रतिक्रिया को कुंजी के साथ प्रमाणित करने की कोशिश हो रही है, जो मुझे पता है कि दूसरे छोर के पास यहां नहीं है।

आईडी को मैन्युअल रूप से कॉपी करने के बजाय, प्रयास क्यों न करें ssh-copy-id- अपना पासवर्ड दर्ज करें और यह अपडेट हो जाएगा authorized_keys। यह (ए) निश्चित रूप से उसी कुंजी का sshचयन करना चाहिए जैसा चयन करना चाहिए, (बी) सुनिश्चित करें कि आपने गलती से कोई स्वरूपण त्रुटियों को नहीं जोड़ा है।

यदि वह आपके लिए काम करता है, तो authorized_keysद्वारा जोड़ी गई रेखा की तुलना करें ssh-copy-idऔर उम्मीद है कि आप समझ जाएंगे कि क्या गलत हुआ।


यह काम करता है, बहुत बहुत धन्यवाद! यह पता चला है कि मैं authorized_keysफ़ाइल नाम के साथ एक टाइपो था । मैंने हर तरीके को आज़माया था और कई बार फ़ाइलनाम की जाँच की (मैंने फ़ाइलनाम टाइपो के बारे में कुछ पढ़ा), लेकिन ... नींद आने पर आँखें अच्छी तरह से काम नहीं करेंगी ...
लेटोम

ssh-copy-idमेरे लिए ट्रिक का उपयोग करना
Asaf

यह पूरी तरह से काम करता है ... जब तक आपके पास एक मैक नहीं है। :)
फिक्सिंग

@ brew install ssh-copy-idअगर आप homebrew का उपयोग करते हैं
ग्रेग

1
ये सटीक लक्षण तब भी प्रकट हो सकते हैं यदि आपके पास SELinux सक्षम और गलत तरीके से कॉन्फ़िगर किया गया है, जो sshd को अधिकृत_की फ़ाइल को पढ़ने से रोकता है (SELinux ऑडिट लॉग को देखे बिना हमेशा स्पष्ट नहीं होता है, क्योंकि SELinux पर्याप्त रूप से दानेदार है जो आप आसानी से प्राप्त कर सकते हैं। एक राज्य जहां मैनुअल उपयोगकर्ता के रूप में पढ़ता है या sudo के माध्यम से सफल हो सकता है)
mtraceur

5

अनुमतियाँ समस्या का एक अन्य प्रकार हो सकती हैं, जिससे प्यूबिकेई प्रमाणीकरण विफल हो सकता है: जांचें कि आपके ~और ~/.sshनिर्देशिकाएं आपके उपयोगकर्ता के अलावा किसी के द्वारा भी पठनीय नहीं हैं ( chmod 700 ~ && chmod 700 ~/.sshइसे ठीक कर सकते हैं)।

संपादित करें: अनुमति 750 के लिए ~भी ठीक होना चाहिए।


क्या यह वास्तव में सच है? अनुमतियाँ ~/मायने नहीं रखतीं, उबंटू में डिफ़ॉल्ट आमतौर पर 755 घर निर्देशिकाओं में है और यह मेरे लिए काम करती है।
उल्फोर

मुझे वास्तव में सामना करना पड़ा (दूरस्थ होस्ट पर) CentOS 7 और OpenSSH_6.4 और OpenSSH_6.6.1 दोनों। बस chmod 700 ~करने से मेरी समस्या हल हो गई है।
एंटोनियोके

आपके लिए अच्छा हैं! लेकिन: इसके अनुसार: askubuntu.com/a/69867/31749 होम-डायरेक्टरी पर कोई ग्रुप-राइट परमिशन नहीं हो सकती है, लेकिन ग्रुप-रीड ठीक होना चाहिए।
उल्फोर

ठीक है, मुझे जांचना चाहिए कि उस प्रणाली पर मेरे मामले में 750 काम करता है या नहीं।
एंटोनियोके

2
बस इसे चेक किया। chmod 750 ~ठीक काम करता है।
एंटोनियोके

3

संयोग से, authorized_keysफ़ाइल बनाते समय , क्या आपने अपना फ़ाइल नाम याद नहीं किया है (क्योंकि आपने इसे authorzied_keysप्रश्न के रूप में लिखा है (i और z Exchange), ऐसी संभावना है कि आपने फ़ाइल को उसी तरह नाम दिया है) ssh config फ़ाइल में, फ़ाइल का नाम विशेष रूप से उल्लेख किया गया है

AuthorizedKeysFile %h/.ssh/authorized_keys

इसलिए, आपको विशेष रूप से यह बताने की आवश्यकता है कि फ़ाइल नाम समान है। तो बस फ़ाइल नाम सत्यापित करें।


3

कभी-कभी आपको निजी कुंजी को -i के साथ स्पष्ट रूप से प्रदान करने की आवश्यकता होती है

उदाहरण: ssh -i /root/.ssh/id_rsa2 user@remote


1
यह यहाँ समस्या नहीं है, लेकिन वैसे भी अच्छी बात है।
LittleByBlue
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.