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 がありません。だからどこかに間違った構成があると思います。