設定 SSH-Jumphost |帶有 freeIPA 和 Kerberos-Tickets 的 Proxyjump

設定 SSH-Jumphost |帶有 freeIPA 和 Kerberos-Tickets 的 Proxyjump

我想設定一個堡壘(ssh 跳轉主機)來存取防火牆後面的網路。兩台伺服器都位於 freeIPA 網域中。客戶端是使用者計算機,不屬於 IPA 網域。

網際網路/客戶端 —> SSH-Jumphost —> 登入節點

我的計劃是透過憑證登入 ssh-jumphost 以獲得有效的 TGT,然後透過獲得的 kerberos 票證 ssh 到登入伺服器。

因此,我更改了允許轉送 GSSAPI-Credentials 的 ssh 和 sshd 配置。

# IPA-related configuration changes to sshd_config

PubkeyAuthentication yes
KerberosAuthentication no
GSSAPIAuthentication yes
UsePAM yes
ChallengeResponseAuthentication yes
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
AuthorizedKeysCommandUser nobody

# added
PasswordAuthentication no

以及 ssh 配置:

# IPA-related configuration changes to ssh_config
#
PubkeyAuthentication yes
GlobalKnownHostsFile /var/lib/sss/pubconf/known_hosts
#VerifyHostKeyDNS yes

# assumes that if a user does not have shell (/sbin/nologin),
# this will return nonzero exit code and proxy command will be ignored
Match exec true
        ProxyCommand /usr/bin/sss_ssh_knownhostsproxy -p %p %h


#added 
GSSAPIAuthentication yes
GSSAPITrustDns yes
GSSAPIKeyExchange yes
GSSAPIRenewalForcesRekey yes
Host login
    GSSAPIDelegateCredentials yes

如果我使用 ssh 登入跳轉主機,我會收到有效的 kerberos 票證。之後我可以 ssh 登入而無需輸入憑證

 $(j@client) ssh jumphost
(USER@jumphost) password:
$(@jumphost) klist
Credential-Cache: KCM:1791600003:19884
Standard-Principal: user@REALM

Valid starting       Expires              Service principal
22.11.2022 17:45:38  23.11.2022 17:35:51  krbtgt/REALM@REALM
$(@jumphost) ssh login

$(@login) klist
Credential-Cache: KCM:1791600003:66779
Standard-Principal: user@REALM

Valid starting       Expires              Service principal
22.11.2022 17:47:51  23.11.2022 17:35:51  krbtgt/REALM@REALM

但如果我嘗試一步完成此操作,我需要為每台伺服器輸入我的憑證:

$(@client) ssh -J jumphost login
(user@jumphost) Password: 
(user@login) Password: 

之後我登入並擁有有效的 TGT,但我不知道為什麼需要輸入密碼兩次。

我只想被迫輸入一次密碼。

我也在客戶端上嘗試了不同的 ssh 配置。

Host login
  User USER
  #GSSAPIAuthentication yes
  #GSSAPIDelegateCredentials yes
  HostName login
  ProxyJump USER@jumphost

有和沒有 GSSAPI 選項。

Host jumphost
  User USER
  HostName jumphost

Host login
  User USER
  #GSSAPIAuthentication yes
  #GSSAPIDelegateCredentials yes
  HostName login
  ProxyJump jumphost

有和沒有 GSSAPI 選項。

所有版本都會導致這種情況,我需要提供兩次密碼。

我缺什麼?

編輯:新增了 krb5.conf

#File modified by ipa-client-install

includedir /etc/krb5.conf.d/
includedir /var/lib/sss/pubconf/krb5.include.d/

[libdefaults]
  default_realm = RELAM
  dns_lookup_realm = true
  rdns = false
  dns_canonicalize_hostname = false
  dns_lookup_kdc = true
  ticket_lifetime = 24h
  forwardable = true
  udp_preference_limit = 0
  default_ccache_name = KEYRING:persistent:%{uid}


[realms]
  REALM = {
    pkinit_anchors = FILE:/var/lib/ipa-client/pki/kdc-ca-bundle.pem
    pkinit_pool = FILE:/var/lib/ipa-client/pki/ca-bundle.pem

  }

[domain_realm]
  .realm.com = REALM
  realm.com = REALM
  jumphost.realm.com = REALM

/etc/krb5.conf.d下有以下文件

crypto-policies  freeipa  kcm_default_ccache  sssd_enable_idp

答案1

編輯我猜我錯了:-)

SSH 設定對我來說看起來不錯。我猜簽發的機票不可轉寄。

引用man 5 krb5.conf

庫預設部分

[...]
可轉發
如果設定了此標誌,預設初始票證將是可轉發的。該標誌的預設值為 false。

答案2

我認為您誤解了 ssh 的 -J 選項的作用。它使用跳轉主機建立到最終目的地的套接字連接以代理該連接,但它仍然是與最終目的地協商金鑰和身份驗證的原始主機。您可能會在以下方面更幸運:

ssh -t jumphost 'ssh -t login'

相關內容