Score:2

การรับรองความถูกต้องตามโฮสต์ ssh บน Fedora 35

ธง il
MMM

ฉันพยายามเลี่ยงการถามรหัสผ่านและใช้การรับรองความถูกต้องตามโฮสต์

ไคลเอ็นต์อยู่ใน shosts.equiv ไคลเอนต์คีย์สาธารณะอยู่ใน ssh_known_hosts และยังบังคับให้ถามรหัสผ่าน

เกี่ยวข้องกับ SELInux และ PAM หรือไม่

opensh-8.7p1-3.fc35 และ opensh-server-8.7p1-3.fc35

เซิร์ฟเวอร์

-rw-r--r--. 1 รูท รูท /etc/ssh/ssh_known_hosts    
H,H.lan,H.lan.,192.168.1.86 ssh-rsa <Hpublickey1>
H,H.lan,H.lan.,192.168.1.86 ecdsa-sha2-nistp256 <Hpublickey2>
H,H.lan,H.lan.,192.168.1.86 ssh-ed25519 <Hpublickey3>

และ

-rw-r-----. 1 รูท รูท /etc/ssh/shosts.equiv
ชม
ฮ.ลาน
ฮ.ลาน
192.168.1.86

และ

sshd -T | grep ^โฮสต์
การรับรองความถูกต้องตามโฮสต์ใช่
hostbasedusesnamefrompacketonly ใช่
อัลกอริทึมตามโฮสต์ที่ยอมรับ @openssh.com,[email protected],[email protected],[email protected],rsa [email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh [email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
อัลกอริทึมคีย์โฮสต์ ecdsa-sha2-nistp256,[email protected],[email protected],[email protected],ecdsa -sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,ssh-ed25519-cert-v01 @openssh.com,[email protected],[email protected],rsa-sha2-256,[email protected],rsa -sha2-512,[email protected]
คีย์โฮสต์ /etc/ssh/ssh_host_rsa_key
โฮสต์คีย์ /etc/ssh/ssh_host_ecdsa_key
คีย์โฮสต์ /etc/ssh/ssh_host_ed25519_key
ใช้ PAM ใช่

ลูกค้า : ชื่อโฮสต์ = H

ความพยายามในการเชื่อมต่อบังคับให้ขอรหัสผ่าน

เซิร์ฟเวอร์ ssh
รหัสผ่านของ user@server: 

ด้วยการดีบัก

ssh -o PreferredAuthentications=hostbased -vvv -E /tmp/s.log เซิร์ฟเวอร์

นี่คือเนื้อหาของ s.log

แมว /tmp/s.log 
OpenSSH_8.7p1, OpenSSL 1.1.1l FIPS 24 ส.ค. 2564
debug1: อ่านข้อมูลการกำหนดค่า /home/user/.ssh/config
debug1: อ่านข้อมูลการกำหนดค่า /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config บรรทัดที่ 55: รวมไฟล์ /etc/ssh/ssh_config.d/50-redhat.conf ความลึก 0
debug1: อ่านข้อมูลการกำหนดค่า /etc/ssh/ssh_config.d/50-redhat.conf
debug2: ตรวจสอบการจับคู่สำหรับเซิร์ฟเวอร์โฮสต์ 'สุดท้ายทั้งหมด' เซิร์ฟเวอร์เดิม
debug3: /etc/ssh/ssh_config.d/50-redhat.conf บรรทัดที่ 3: ไม่ตรงกับ 'final'
debug2: ไม่พบการจับคู่
debug3: /etc/ssh/ssh_config.d/50-redhat.conf บรรทัดที่ 5: รวมไฟล์ /etc/crypto-policies/back-ends/openssh.config ความลึก 1 (แยกวิเคราะห์เท่านั้น)
debug1: อ่านข้อมูลการกำหนดค่า /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex ชื่อตกลง: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-]
debug3: ชื่อ kex ตกลง: [curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman -group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512]
debug1: การกำหนดค่าร้องขอ Match pass สุดท้าย
debug1: แยกวิเคราะห์การกำหนดค่าใหม่
debug1: อ่านข้อมูลการกำหนดค่า /home/user/.ssh/config
debug1: อ่านข้อมูลการกำหนดค่า /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config บรรทัดที่ 55: รวมไฟล์ /etc/ssh/ssh_config.d/50-redhat.conf ความลึก 0
debug1: อ่านข้อมูลการกำหนดค่า /etc/ssh/ssh_config.d/50-redhat.conf
debug2: ตรวจสอบการจับคู่สำหรับเซิร์ฟเวอร์โฮสต์ 'สุดท้ายทั้งหมด' เซิร์ฟเวอร์เดิม
debug3: /etc/ssh/ssh_config.d/50-redhat.conf บรรทัดที่ 3: จับคู่ 'สุดท้าย'
debug2: พบการจับคู่
debug3: /etc/ssh/ssh_config.d/50-redhat.conf บรรทัดที่ 5: รวมไฟล์ /etc/crypto-policies/back-ends/openssh.config ความลึก 1
debug1: อ่านข้อมูลการกำหนดค่า /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex ชื่อตกลง: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-]
debug3: kex ชื่อตกลง: [curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman -group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512]
debug3: ขยาย UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/user/.ssh/known_hosts'
debug3: ขยาย UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/user/.ssh/known_hosts2'
debug2: แก้ไข "เซิร์ฟเวอร์" พอร์ต 22
debug3: ssh_connect_direct: เข้า
debug1: การเชื่อมต่อกับเซิร์ฟเวอร์ [192.168.1.66] พอร์ต 22
debug3: set_sock_tos: ตั้งค่าซ็อกเก็ต 4 IP_TOS 0x48
debug1: สร้างการเชื่อมต่อแล้ว
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_rsa ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_rsa-cert ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_dsa ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_dsa-cert ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ecdsa ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ecdsa-cert ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ecdsa_sk ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ecdsa_sk-cert type -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ed25519 ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ed25519-cert type -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ed25519_sk ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_ed25519_sk-cert ประเภท -1
debug1: ไฟล์ข้อมูลประจำตัว /home/user/.ssh/id_xmss ประเภท -1
debug1: ไฟล์ระบุตัวตน /home/user/.ssh/id_xmss-cert type -1
debug1: สตริงเวอร์ชันท้องถิ่น SSH-2.0-OpenSSH_8.7
debug1: โปรโตคอลระยะไกลเวอร์ชัน 2.0, ซอฟต์แวร์ระยะไกลเวอร์ชัน OpenSSH_8.7
debug1: compat_banner: จับคู่: OpenSSH_8.7 pat OpenSSH* เข้ากันได้กับ 0x04000000
debug2: fd 4 ตั้งค่า O_NONBLOCK
debug1: รับรองความถูกต้องไปยังเซิร์ฟเวอร์: 22 ในฐานะ 'ผู้ใช้'
debug3: record_hostkey: พบคีย์ประเภท ED25519 ในไฟล์ /home/user/.ssh/known_hosts:4
debug3: record_hostkey: พบประเภทคีย์ RSA ในไฟล์ /home/user/.ssh/known_hosts:5
debug3: record_hostkey: พบคีย์ประเภท ECDSA ในไฟล์ /home/user/.ssh/known_hosts:6
debug3: load_hostkeys_file: โหลด 3 คีย์จากเซิร์ฟเวอร์
debug1: load_hostkeys: fopen /home/user/.ssh/known_hosts2: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug3: order_hostkeyalgs: มีประเภทคีย์การตั้งค่าที่ดีที่สุดที่ตรงกัน [email protected] โดยใช้ HostkeyAlgorithms คำต่อคำ
debug3: ส่งแพ็คเก็ต: ประเภท 20
debug1: ส่ง SSH2_MSG_KEXINIT แล้ว
debug3: รับแพ็กเก็ต: พิมพ์ 20
debug1: ได้รับ SSH2_MSG_KEXINIT แล้ว
debug2: ข้อเสนอ KEXINIT ของลูกค้าในพื้นที่
debug2: อัลกอริทึม KEX: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14 -sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,ext-info-c
debug2: อัลกอริทึมคีย์โฮสต์: [email protected],[email protected],[email protected],ecdsa-sha2- [email protected],[email protected],[email protected],rsa-sha2-512-cert-v01@ opensh.com,[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2- nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac -sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac -sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: การบีบอัด ctos: none,[email protected],zlib
debug2: การบีบอัด stoc: none,[email protected],zlib
debug2: ภาษา ctos: 
debug2: ภาษา stoc: 
debug2: first_kex_follow 0 
debug2: สงวนไว้ 0 
debug2: ข้อเสนอเพียร์เซิร์ฟเวอร์ KEXINIT
debug2: อัลกอริทึม KEX: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14 -sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
debug2: อัลกอริทึมคีย์โฮสต์: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,[email protected],aes128-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac -sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac -sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: การบีบอัด ctos: none,[email protected]
debug2: การบีบอัด stoc: none,[email protected]
debug2: ภาษา ctos: 
debug2: ภาษา stoc: 
debug2: first_kex_follow 0 
debug2: สงวนไว้ 0 
debug1: kex: อัลกอริทึม: curve25519-sha256
debug1: kex: อัลกอริทึมคีย์โฮสต์: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> การบีบอัด: ไม่มี
debug1: kex: client->server cipher: [email protected] MAC: <implicit> การบีบอัด: ไม่มี
debug1: kex: curve25519-sha256 ต้องการ = 32 dh_need = 32
debug1: kex: curve25519-sha256 ต้องการ = 32 dh_need = 32
debug3: ส่งแพ็คเก็ต: ประเภท 30
debug1: คาดหวัง SSH2_MSG_KEX_ECDH_REPLY
debug3: รับแพ็กเก็ต: ประเภท 31
debug1: ได้รับ SSH2_MSG_KEX_ECDH_REPLY แล้ว
debug1: รหัสโฮสต์เซิร์ฟเวอร์: ssh-ed25519 SHA256:Uy8VMmU9e9OnnoJWzLrojVNFaDk6LJiNR9asnFJy57g
debug3: record_hostkey: พบคีย์ประเภท ED25519 ในไฟล์ /home/user/.ssh/known_hosts:4
debug3: record_hostkey: พบประเภทคีย์ RSA ในไฟล์ /home/user/.ssh/known_hosts:5
debug3: record_hostkey: พบคีย์ประเภท ECDSA ในไฟล์ /home/user/.ssh/known_hosts:6
debug3: load_hostkeys_file: โหลด 3 คีย์จากเซิร์ฟเวอร์
debug1: load_hostkeys: fopen /home/user/.ssh/known_hosts2: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
debug1: โฮสต์ 'เซิร์ฟเวอร์' เป็นที่รู้จักและตรงกับรหัสโฮสต์ ED25519
debug1: พบรหัสใน /home/user/.ssh/known_hosts:4
debug3: ส่งแพ็คเก็ต: ประเภท 21
debug2: set_newkeys: โหมด 1
debug1: คีย์ใหม่หลังจากบล็อก 4294967296
debug1: ส่ง SSH2_MSG_NEWKEYS แล้ว
debug1: คาดหวัง SSH2_MSG_NEWKEYS
debug3: รับแพ็กเก็ต: พิมพ์ 21
debug1: ได้รับ SSH2_MSG_NEWKEYS แล้ว
debug2: set_newkeys: โหมด 0
debug1: ป้อนใหม่หลังจากบล็อก 4294967296
debug1: จะพยายามคีย์: /home/user/.ssh/id_rsa 
debug1: จะพยายามคีย์: /home/user/.ssh/id_dsa 
debug1: จะพยายามคีย์: /home/user/.ssh/id_ecdsa 
debug1: จะพยายามคีย์: /home/user/.ssh/id_ecdsa_sk 
debug1: จะพยายามคีย์: /home/user/.ssh/id_ed25519 
debug1: จะพยายามคีย์: /home/user/.ssh/id_ed25519_sk 
debug1: จะพยายามคีย์: /home/user/.ssh/id_xmss 
debug2: pubkey_prepare: เสร็จแล้ว
debug3: ส่งแพ็กเก็ต: ประเภท 5
debug3: รับแพ็กเก็ต: ประเภท 7
debug1: ได้รับ SSH2_MSG_EXT_INFO แล้ว
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256 ,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug3: รับแพ็กเก็ต: ประเภท 6
debug2: service_accept: ssh-userauth
debug1: ได้รับ SSH2_MSG_SERVICE_ACCEPT แล้ว
debug3: ส่งแพ็คเก็ต: ประเภท 50
debug3: รับแพ็กเก็ต: พิมพ์ 51
debug1: การรับรองความถูกต้องที่สามารถดำเนินการต่อได้: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased
debug3: เริ่มต้นใหม่, ส่ง publickey รายการอื่น, gssapi-keyex, gssapi-with-mic, รหัสผ่าน, ตามโฮสต์
debug3: โฮสต์ที่ต้องการ
debug3: authmethod_lookup ตามโฮสต์
debug3: เหลือที่ต้องการ: 
debug1: ไม่ต้องลองวิธีการรับรองความถูกต้องอีกต่อไป
user@server: การอนุญาตถูกปฏิเสธ (publickey, gssapi-keyex, gssapi-with-mic, รหัสผ่าน, ตามโฮสต์)
dave_thompson_085 avatar
jp flag
ค่าเริ่มต้นรหัสไคลเอนต์ (`ssh`) สำหรับโฮสต์ปิดอยู่ เว้นแต่ว่าเปิดในไฟล์กำหนดค่าที่คุณไม่ได้แสดง ให้ลองเพิ่ม `-o HostBasedAuthentication=yes` (หรือ `true`)
MMM avatar
il flag
MMM
หลังจากอ่านที่นี่ https://www.usenix.org/system/files/login/articles/09_singer.pdf และที่นี่ https://utcc.utoronto.ca/~cks/space/blog/sysadmin/OpenSSHUseDNSErrorAnnoyance นี่คือรายการของการกระทำ: 1. ฝั่งไคลเอนต์ตั้งค่า HostbasedAuthentication เป็นจริงสำหรับโฮสต์เป้าหมาย ตั้งค่า EnableSSHKeysign ใช่ จากนั้นที่ฝั่งเซิร์ฟเวอร์ ให้ตั้งค่า UseDNS เป็นใช่ และให้ไคลเอนต์โฮสต์ของคุณอยู่ใน global shosts.equiv และคีย์ใน ssh_known_hosts
dave_thompson_085 avatar
jp flag
ในการตรวจสอบแหล่งที่มา ฉันยอมรับว่าจำเป็นต้องมีการเปิดใช้งาน SSHKeysign ไม่ควรใช้ UseDNS เนื่องจากคุณมี hostbasedusesnamefrompacketonly แต่ก็ไม่ควรเสียหายเช่นกัน

โพสต์คำตอบ

คนส่วนใหญ่ไม่เข้าใจว่าการถามคำถามมากมายจะปลดล็อกการเรียนรู้และปรับปรุงความสัมพันธ์ระหว่างบุคคล ตัวอย่างเช่น ในการศึกษาของ Alison แม้ว่าผู้คนจะจำได้อย่างแม่นยำว่ามีคำถามกี่ข้อที่ถูกถามในการสนทนา แต่พวกเขาไม่เข้าใจความเชื่อมโยงระหว่างคำถามและความชอบ จากการศึกษาทั้ง 4 เรื่องที่ผู้เข้าร่วมมีส่วนร่วมในการสนทนาด้วยตนเองหรืออ่านบันทึกการสนทนาของผู้อื่น ผู้คนมักไม่ตระหนักว่าการถามคำถามจะมีอิทธิพลหรือมีอิทธิพลต่อระดับมิตรภาพระหว่างผู้สนทนา