Windows 클라이언트에서 Kerberos를 사용하는 SSH

Windows 클라이언트에서 Kerberos를 사용하는 SSH

SSSD를 사용하여 Active Directory에 가입한 Ubuntu 22.04 LTS 시스템이 있습니다. 모든 것이 괜찮습니다. AD 사용자를 사용하여 Linux 서버에 로그인할 수 있고, 사용자는 로그인할 때 Kerberos 티켓 등을 받습니다.

클라이언트가 Kerberos를 사용하여 이 시스템에 SSH로 접속할 수 있도록 하여 로그인할 때 비밀번호를 입력할 필요가 없도록 하고 싶습니다.

Ubuntu 서버에서 다음을 포함하도록 /etc/ssh/sshd_config를 편집했습니다.

GSSAPIAuthentication yes

sshd 서비스를 다시 시작하십시오. 이제 동일한 AD에 가입된 Windows 컴퓨터에서 PowerShell을 열고 다음을 입력하면ssh -K ubuntu-server1.domain.local사용자 이름과 비밀번호를 입력하라는 메시지가 표시됩니다.도메인\사용자 이름1 GSSAPI 인증을 활성화하기 위해 Putty를 사용해 보았지만 운이 없었습니다.

온갖 설정을 다 해본 것 같은 느낌sshd_conf퍼티에는 행운이 없습니다. 또한 Windows 컴퓨터에 SSH 서버를 설치하고 활성화했습니다.GSSAPI 인증이를 위해 다음 명령을 사용하여 Linux 서버에서 Windows 클라이언트에 로그인할 수 있습니다.ssh -K windows-client1.domain.local비밀번호 입력 없이 바로 로그인이 가능합니다..

역방향 조회를 포함하여 DNS가 정확합니다. 시기도 맞습니다.

Linux 상자를 AD에 가입할 때 방금 실행했습니다.

realm join domain.local

난 아직 많은 일을 하지 않았어/etc/sssd/sssd.conf몇 가지 변경 사항 이상:

[sssd]
domains = domain.local
config_file_version = 2
services = nss, pam, sudo

[domain/domain.local]
default_shell = /bin/bash
krb5_store_password_if_offline = True
cache_credentials = True
krb5_realm = DOMAIN.LOCAL
realmd_tags = manages-system joined-with-adcli
id_provider = ad
fallback_homedir = /home/%d/%u
ad_domain = DOMAIN.local
ad_hostname = ubuntu-server1.domain.local
use_fully_qualified_names = True
ldap_id_mapping = True
access_provider = simple
sudo_provider = ad

dyndns_update = true
dyndns_refresh_interval = 43200
dyndns_update_ptr = true
dyndns_ttl = 3600
simple_allow_groups = [email protected]

[sudo]

이것/etc/krb5.conf너무 많이하지:

[libdefaults]
udp_preference_limit = 0
default_realm = DOMAIN.LOCAL

DNS가 올바른지 여러 번 확인했습니다. PTR 레코드를 포함하여 모든 것을 찾을 수 있습니다.

문제 해결을 더 쉽게 하기 위해 다음과 같이 Linux 시스템에서 별도의 sshd 서비스를 시작했습니다.

KRB5_TRACE=/tmp/ssh-krb5trace /sbin/sshd -D -d -p 2222

비밀번호 프롬프트를 받고 CTRL+C로 취소한 후 이 메시지를 받았습니다.

debug1: sshd version OpenSSH_8.9, OpenSSL 3.0.2 15 Mar 2022
debug1: private host key #0: ssh-rsa SHA256:I0ONIQ8tkt6KIoX12VZI2exO3e9HCiY8qsykdJ3lvK0
debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:Ab/OZTiog2d/tptR8g/xDvdXGWIxU3cas1glKE1i3l4
debug1: private host key #2: ssh-ed25519 SHA256:07VGrICNBYTljMqraC9tx0MxzShBXXaS5dHsQQ2Of3Q
debug1: rexec_argv[0]='/sbin/sshd'
debug1: rexec_argv[1]='-D'
debug1: rexec_argv[2]='-d'
debug1: rexec_argv[3]='-p'
debug1: rexec_argv[4]='2222'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 2222 on 0.0.0.0.
Server listening on 0.0.0.0 port 2222.
debug1: Bind to port 2222 on ::.
Server listening on :: port 2222.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: sshd version OpenSSH_8.9, OpenSSL 3.0.2 15 Mar 2022
debug1: private host key #0: ssh-rsa SHA256:I0ONIQ8tkt6KIoX12VZI2exO3e9HCiY8qsykdJ3lvK0
debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:Ab/OZTiog2d/tptR8g/xDvdXGWIxU3cas1glKE1i3l4
debug1: private host key #2: ssh-ed25519 SHA256:07VGrICNBYTljMqraC9tx0MxzShBXXaS5dHsQQ2Of3Q
debug1: inetd sockets after dupping: 3, 3
Connection from 192.168.1.120 port 49983 on 10.0.0.230 port 2222 rdomain ""
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.1
debug1: compat_banner: match: OpenSSH_for_Windows_8.1 pat OpenSSH* compat 0x04000000
debug1: permanently_set_uid: 110/65534 [preauth]
debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: algorithm: curve25519-sha256 [preauth]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none [preauth]
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: SSH2_MSG_KEX_ECDH_INIT received [preauth]
debug1: rekey out after 134217728 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: Sending SSH2_MSG_EXT_INFO [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: rekey in after 134217728 blocks [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user domain\\\\username1 service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "domain\\username1"
debug1: PAM: setting PAM_RHOST to "192.168.1.120"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user domain\\\\username1 service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: userauth_pubkey: publickey test pkalg rsa-sha2-512 pkblob RSA SHA256:zxEs2+751dYAs84032EwQZxYOqA0js4k0mqI/rfU08w [preauth]
debug1: temporarily_use_uid: 217401201/217400513 (e=0/0)
debug1: trying public key file /home/domain.local/username1/.ssh/authorized_keys
debug1: Could not open authorized keys '/home/domain.local/username1/.ssh/authorized_keys': No such file or directory
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 217401201/217400513 (e=0/0)
debug1: trying public key file /home/domain.local/username1/.ssh/authorized_keys2
debug1: Could not open authorized keys '/home/domain.local/username1/.ssh/authorized_keys2': No such file or directory
debug1: restore_uid: 0/0
Failed publickey for domain\\username1 from 192.168.1.120 port 49983 ssh2: RSA SHA256:zxEs2+751dYAs84032EwQZxYOqA0js4k0mqI/rfU08w
Connection reset by authenticating user domain\\\\username1 192.168.1.120 port 49983 [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: PAM: cleanup
debug1: Killing privsep child 964423
debug1: audit_event: unhandled event 12

난 아무것도 없어/tmp/ssh-krb5trace비밀번호로 로그인하지 않으면 다음과 같습니다.

[963733] 1700139671.168219: Getting initial credentials for [email protected]
[963733] 1700139671.168222: Sending unauthenticated request
[963733] 1700139671.168223: Sending request (193 bytes) to domain.local
[963733] 1700139671.168224: Sending DNS URI query for _kerberos.domain.local.
[963733] 1700139671.168225: No URI records found
[963733] 1700139671.168226: Sending DNS SRV query for _kerberos._udp.domain.local.
[963733] 1700139671.168227: SRV answer: 0 100 88 "domain-dc02.domain.local."
[963733] 1700139671.168228: SRV answer: 0 100 88 "domain-dc01.domain.local."
[963733] 1700139671.168229: Sending DNS SRV query for _kerberos._tcp.domain.local.
[963733] 1700139671.168230: SRV answer: 0 100 88 "domain-dc01.domain.local."
[963733] 1700139671.168231: SRV answer: 0 100 88 "domain-dc02.domain.local."
[963733] 1700139671.168232: Resolving hostname domain-dc02.domain.local.
[963733] 1700139671.168233: Resolving hostname domain-dc01.domain.local.
[963733] 1700139671.168234: Resolving hostname domain-dc01.domain.local.
[963733] 1700139671.168235: Initiating TCP connection to stream 10.100.1.5:88
[963733] 1700139671.168236: Sending TCP request to stream 10.100.1.5:88
[963733] 1700139671.168237: Received answer (192 bytes) from stream 10.100.1.5:88
[963733] 1700139671.168238: Terminating TCP connection to stream 10.100.1.5:88
[963733] 1700139671.168239: Sending DNS URI query for _kerberos.domain.local.
[963733] 1700139671.168240: No URI records found
[963733] 1700139671.168241: Sending DNS SRV query for _kerberos-master._tcp.domain.local.
[963733] 1700139671.168242: No SRV records found
[963733] 1700139671.168243: Response was not from primary KDC
[963733] 1700139671.168244: Received error from KDC: -1765328359/Additional pre-authentication required
[963733] 1700139671.168247: Preauthenticating using KDC method data
[963733] 1700139671.168248: Processing preauth types: PA-PK-AS-REQ (16), PA-PK-AS-REP_OLD (15), PA-ETYPE-INFO2 (19), PA-ENC-TIMESTAMP (2)
[963733] 1700139671.168249: Selected etype info: etype aes256-cts, salt "domain.LOCALusername1", params ""
[963733] 1700139671.168250: AS key obtained for encrypted timestamp: aes256-cts/66C7
[963733] 1700139671.168252: Encrypted timestamp (for 1700139671.649114): plain 301AA011180F32303233313131363133303131315AA105020309E79A, encrypted 57F8E4BB1AA92F9A66F4E7E6135EE823285830662C1F040754995BF8ED42D9913EE1403B8E7FC92211FD04D313ED3D56F83675F2B5DA4E03
[963733] 1700139671.168253: Preauth module encrypted_timestamp (2) (real) returned: 0/Success
[963733] 1700139671.168254: Produced preauth for next request: PA-ENC-TIMESTAMP (2)
[963733] 1700139671.168255: Sending request (273 bytes) to domain.local
[963733] 1700139671.168256: Sending DNS URI query for _kerberos.domain.local.
[963733] 1700139671.168257: No URI records found
[963733] 1700139671.168258: Sending DNS SRV query for _kerberos._udp.domain.local.
[963733] 1700139671.168259: SRV answer: 0 100 88 "domain-dc01.domain.local."
[963733] 1700139671.168260: SRV answer: 0 100 88 "domain-dc02.domain.local."
[963733] 1700139671.168261: Sending DNS SRV query for _kerberos._tcp.domain.local.
[963733] 1700139671.168262: SRV answer: 0 100 88 "domain-dc02.domain.local."
[963733] 1700139671.168263: SRV answer: 0 100 88 "domain-dc01.domain.local."
[963733] 1700139671.168264: Resolving hostname domain-dc01.domain.local.
[963733] 1700139671.168265: Resolving hostname domain-dc02.domain.local.
[963733] 1700139671.168266: Resolving hostname domain-dc02.domain.local.
[963733] 1700139671.168267: Initiating TCP connection to stream 192.168.1.5:88
[963733] 1700139671.168268: Sending TCP request to stream 192.168.1.5:88
[963733] 1700139671.168269: Received answer (1793 bytes) from stream 192.168.1.5:88
[963733] 1700139671.168270: Terminating TCP connection to stream 192.168.1.5:88
[963733] 1700139671.168271: Sending DNS URI query for _kerberos.domain.local.
[963733] 1700139671.168272: No URI records found
[963733] 1700139671.168273: Sending DNS SRV query for _kerberos-master._tcp.domain.local.
[963733] 1700139671.168274: No SRV records found
[963733] 1700139671.168275: Response was not from primary KDC
[963733] 1700139671.168276: Processing preauth types: PA-ETYPE-INFO2 (19)
[963733] 1700139671.168277: Selected etype info: etype aes256-cts, salt "domain.LOCALusername1", params ""
[963733] 1700139671.168278: Produced preauth for next request: (empty)
[963733] 1700139671.168279: AS key determined by preauth: aes256-cts/66C7
[963733] 1700139671.168280: Decrypted AS reply; session key is: aes256-cts/E1E4
[963733] 1700139671.168281: FAST negotiation: unavailable
[963733] 1700139671.168282: Retrying AS request with primary KDC
[963733] 1700139671.168283: Getting initial credentials for [email protected]
[963733] 1700139671.168285: Sending unauthenticated request
[963733] 1700139671.168286: Sending request (193 bytes) to domain.local (primary)
[963733] 1700139671.168287: Sending DNS URI query for _kerberos.domain.local.
[963733] 1700139671.168288: No URI records found
[963733] 1700139671.168289: Sending DNS SRV query for _kerberos-master._udp.domain.local.
[963733] 1700139671.168290: Sending DNS SRV query for _kerberos-master._tcp.domain.local.
[963733] 1700139671.168291: No SRV records found

아직 Kerberos와 SSSD에 대해 충분히 알지 못하는 것 같아서 간단한 것을 간과하고 있을 수도 있습니다. 이에 대한 정보가 도움이 될 것입니다!

편집: Windows 시스템의 로그를 포함하는 것을 잊었습니다. kerberos를 강제로 실행했습니다.-o PreferredAuthentications=gssapi-with-mic

> ssh -v -K -o PreferredAuthentications=gssapi-with-mic ubuntu-server1.domain.local
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\username1/.ssh/config
debug1: Connecting to ubuntu-server1.domain.local [10.0.0.230] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\username1/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\username1/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\username1/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\username1/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\username1/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\username1/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\username1/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\username1/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\username1/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\username1/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.4
debug1: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to ubuntu-server1.domain.local:22 as 'domain\\username1'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Ab/OZTiog2d/tptR8g/xDvdXGWIxU3cas1glKE1i3l4
debug1: Host 'ubuntu-server1.domain.local' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\username1/.ssh/known_hosts:8
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\username1/.ssh/id_rsa RSA SHA256:zxEs2+751dYAs84032EwQZxYOqA0js4k0mqI/rfU08w
debug1: Will attempt key: C:\\Users\\username1/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\username1/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\username1/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\username1/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
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]>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: GSS_S_FAILURE
debug1: No more authentication methods to try.
domain\\[email protected]: Permission denied (publickey,gssapi-with-mic,password).

그래서 나는 얻는다GSS_S_실패몇 가지 이유. 이에 대해 조사해보겠습니다. 도움을 주시면 감사하겠습니다.

편집 2:

그래서 조금 더 나아갔습니다. 이제 문제 해결 SSHD에 연결하면 다음 메시지가 나타납니다.

debug1: No credentials were supplied, or the credentials were unavailable or inaccessible
No key table entry found matching host/ubuntu-server1.domain.local@

저는 Kerberos 전문가는 아니지만 조금 이상한 것 같습니다. 내 키탭을 보면 다음과 같은 결과가 나타납니다.

[username1@ubuntu-server1:~]$ sudo ktutil
ktutil:  read_kt /etc/krb5.keytab
ktutil:  l
slot KVNO Principal
---- ---- ---------------------------------------------------------------------
   1    2              [email protected]
   2    2              [email protected]
   3    2              [email protected]
   4    2          host/[email protected]
   5    2          host/[email protected]
   6    2          host/[email protected]
   7    2 host/[email protected]
   8    2 host/[email protected]
   9    2 host/[email protected]
  10    2 RestrictedKrbHost/[email protected]
  11    2 RestrictedKrbHost/[email protected]
  12    2 RestrictedKrbHost/[email protected]
  13    2 RestrictedKrbHost/[email protected]
  14    2 RestrictedKrbHost/[email protected]
  15    2 RestrictedKrbHost/[email protected]

Host/ubuntu-server1.domain.local@에 해당하지 않으며 마지막으로 DOMAIN.LOCAL이 누락되었습니다. 그래서 어딘가에 잘못된 구성이 있는 것 같아요.. 그런데 어디에요?

관련 정보