歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> Unix基礎知識 >> 在AIX V5.3中使用OpenSSH保護通信安全

在AIX V5.3中使用OpenSSH保護通信安全

日期:2017/3/3 15:24:24   编辑:Unix基礎知識

簡介:學習如何在使用Microsoft® Active Directory Server作為密鑰分發中心(KDC) 的 AIX® Version 5.3計算機上配置Kerberized Open Secure Shell(OpenSSH)。OpenSSH 對通信(包括 密碼)進行加密以防止竊聽、接管通信連接或窺視數據。如果您工作於具有多供應商解決方案混合環境中 的 AIX Version 5.3 系統,那麼您會發現本文是非常有價值的。

引言

Open Secure Shell(OpenSSH) 是廣泛使用的 SSH 工具中的一種免費的、開放源碼的實現,SSH 工具廣泛地用於在網絡 之間進行安全的通信。通過對兩台計算機之間的所有通信信息進行加密,它可以排除有人進行探查、接管 或窺視您的私有數據的可能性。OpenSSH 還提供了許多身份驗證機制以實現額外的安全性。

Kerberos 是一種常用的身份驗證機制,它為網絡用戶的身份驗證提供了一種安全手段,並且 OpenSSH 提供了對 Kerberos 的支持。通過對客戶端和服務器之間的身份驗證消息進行加密,它可以防止 在網絡上使用明文來傳輸密碼。Kerberos 還以管理令牌或憑據的形式提供了一種授權系統。用於 IBM AIX® Version 5.3 的 OpenSSH 軟件(openssh-3.8.p1) 是 AIX Version 5.3 Expansion Pack CD 附 帶的軟件。通過 IBM 版本的 Kerberos,稱為IBM Network Authentication Service(IBM NAS) Version 1.4,OpenSSH Version 3.8 以及更高的版本提供了對 Kerberos 5 身份驗證和授權的支持。還可以從AIX Version 5.3 Expansion Pack CD中安裝用於 AIX 的 IBM NAS Version 1.4。

Microsoft® Active Directory Service 是 Windows® 平台的重要組成部分,它為各種網絡管理和身份驗證任務 提供了相應的方法。Kerberos 是 Windows Active Directory 實現中不可缺少的一部分,並且它作為 Kerberos 領域的密鑰分發中心(KDC),廣泛地應用於企業中。可以在Windows Server 2003和Windows Server 2000中配置Microsoft Active Directory Service。

本文將帶您了解在使用Microsoft Active Directory Server作為KDC 的 AIX Version 5.3計算機上配置Kerberized Open Secure Shell (OpenSSH) 所需的步驟。對於那些工作於由 AIX Version 5.3 系統和 Microsoft Active Directory Server 組成的多供應商解決方案的混合環境中的管理員,本文將是非常有幫助的。

先決條件

要按照本文中的場景進行操作,您需要啟動和運行支持 Microsoft Active Directory Domain 的 Kerberos服務,並且需要為其正確地配置AIX IBM NAS Version 1.4 客戶端。

AIX Version 5.3上 的 OpenSSH和Kerberos(IBM NAS)

本部分內容介紹在AIX服務器和客戶端計算機上安裝和配置 Kerberos和OpenSSH 所需的初始步驟。AIX Version 5.3 Expansion Pack CD中附帶了OpenSSH和Kerberos 。在安裝 OpenSSH installp 格式的安裝包之前,您必須安裝包含加密庫的開放安全套接字層(OpenSSL) 軟件。可以從AIX Toolbox for Linux® Applications CD中獲得 OpenSSL 的 RPM 包,或者您也可以 從AIX Toolbox for Linux Applications 進行下載(請參見參考資料部分)。

在將 OpenSSL 下 載到AIX Version 5.3計算機的本地目錄(本示例中為/tmp)之後,可以通過運行下面的命令來安裝它:

# geninstall -d/tmp R:openssl-0.9.6m

您可以使用下面兩種方法中的任 何一種來安裝 OpenSSH:

smitty->Software Installation and Maintenance- >Install and
  Update Software->Install Software

或者

# geninstall -I"Y" -d/dev/cd0 I:openssh.base

安裝 IBM NAS Version 1.4 客戶端,並將其配置為Kerberos 領域(Active Directory 域),該 Kerberos 領域由 Microsoft Active Directory Server 承載並用作 KDC。有關 IBM NAS 客戶端安裝及其對 Microsoft Active Directory Server 配置的更詳細的信息,請閱讀 AIX 白皮書“Configuring AIX 5L for Kerberos Based Authentication Using Windows Kerberos Service”(請參見參考資料部分)。

在成功安裝和配置了IBM NAS 客戶端之後,您需要將 OpenSSH 配置為使用Kerberos 進行身份驗 證。

編輯 /etc/services文件,使其包含下列條目:

kerberos   88/udp   kdc  # Kerberos V5 KDC
kerberos   88/tcp  kdc  # Kerberos V5 KDC
kerberos-adm 749/tcp     # Kerberos 5 admin/changepw
kerberos-adm 749/udp      # Kerberos 5 admin/changepw

在/etc/ssh/sshd_config中取消對下列條目的注釋 以使得 SSH 守護進程使用Kerberos作為其身份驗證機制:

KerberosAuthentication yes
KerberosTicketCleanup yes
# GSSAPI options
GSSAPIAuthentication yes

使用下面的命令啟動SSH服務器:#startsrc -g ssh

使用下面的 命令來確認已正確地啟動了SSH服務器:#ps -ef|grep ssh

AIX Version 5.3上使用 Windows Kerberos服務的 Kerberized OpenSSH

本部分內容描述了一個場景,它將帶您了解在AIX Version 5.3計算機(使用Microsoft Active Directory Server作為KDC)上對 Kerberized SSH 進行配 置所需的步驟。

本部分內容假設您已經啟動和運行支持 Microsoft Active Directory Domain 的 Kerberos服務,並且您已為它成功地配置了AIX IBM NAS Version 1.4 客戶端。有關為Microsoft Active Directory Server 配置IBM NAS Version 1.4 客戶端的更詳細的信息,請參閱 IBM NAS Version 1.4 Administration Guide(AIX Version 5.3 Expansion Pack CD中附帶)以及參考資料部分中的 IBM 白皮 書。

有關安裝和配置Microsoft Active Directory Server 的更詳細的信息,請參閱合適的 Microsoft文檔以了解如何配置Microsoft Active Directory Server。

下面的示例中將使用下列 定義:

Kerberos Realm Name / Domain Name      
  MSKERBEROS.IN.IBM.COM
KDC(Windows Active Directory Server)
  hostname: windce20.in.ibm.com, OS: Windows 2003 Server
SSH Server(sshd)
  hostname: aixdce16.in.ibm.com, OS: AIX Version 5.3
SSH Client
  hostname: aixdce20.in.ibm.com, OS: AIX Version 5.3
IBM NAS 1.4 Client
  hostname: aixdce16.in.ibm.com, OS: AIX Version 5.3 &
  hostname: aixdce20.in.ibm.com, OS: AIX Version 5.3

圖 1 顯示了該示例的設置。

圖 1.示例設置

要在AIX計算機上配置Kerberized SSH 使得 AIX 的 IBM NAS 客戶端配置為Microsoft Active Directory Server,您需要實施下列步驟。

在Windows Active Directory Server上,使用Active Directory管理工具創建一個與運行 SSH服務器 的 AIX計算機相對應的新的用戶帳戶。在本示例中為aixdce16.in.ibm.com。

打開對話框,從Users folder創建一個新的用戶,並完成下面的條目:

First Name = aixdce16.in.ibm.com

Full Name = aixdce16.in.ibm.com

User logon Name = aixdce16.in.ibm.com

User logon Name(Windows 2000 以前的版本)= aixdce16.in.ibm.com

填寫Password,並在密碼面板中選擇合適的復選框。

選擇Finish 以完成用戶的創建。

在Windows Server 2003計算機(windce20.in.ibm.com)命令行中使用Ktpass命令創建 krb5.keytab文件,並為AIX主機(aixdce16.in.ibm.com) 設置相應的帳戶,如下所示:Ktpass - princ host/[email protected] -mapuser
  aixdce16.in.ibm.com -pass !sandeep17! -out c:\krb5.keytab

將在步驟2中創建的 krb5.keytab文件復制到AIX主機系統(在本示例中,將它復制到或 通過 ftp 傳輸到aixdce16.in.ibm.com)的 /tmp 目錄。將 /tmp/krb5.keytab文件合並到AIX 系統的 /etc/krb5/krb5.keytab文件中。請確保這個 keytab文件(/etc/krb5/krb5.keytab)中包含所需的具有正 確的密鑰版本號的 Kerberos服務器主體條目。如果包含該信息,那麼可以在AIX計算機 (aixdce16.in.ibm.com)上啟動SSH服務器,如下所示。

清單1.在AIX中對 keytab文件進行設置# hostname
aixdce16
# ktutil
ktutil: rkt /tmp/krb5.keytab
ktutil: wkt /etc/krb5/krb5.keytab
ktutil: q
# kvno host/aixdce16.in.ibm.com
kvno = 1
# klist -k
Keytab name: FILE:/etc/krb5/krb5.keytab
KVNO Principal
---- ---------
  1 host/[email protected]
# startsrc -g ssh
0513-059 The sshd Subsystem has been started.Subsystem PID is 22698.

請確保 從kvno命令獲得的密鑰版本號可以與 klist -k命令所顯示的 host/<hostname>主體條目匹配。 如果它們無法匹配,那麼您可能需要為keytab文件中的 host/<hostname>主體添加一項匹配密鑰版本號的條目。

在Windows Active Directory Server中,使用Active Directory管理工具創建一個新的用戶 帳號,該用戶帳號的名稱與 AIX計算機上現有的某個用戶帳號的名稱相匹配。在本示例中,我們創建了一 個名為"sandeep" 的用戶帳號,這個帳號也存在於兩台 AIX計算機中。有關如何在Windows Active Directory Server中創建用戶帳號的信息,請參見上面的步驟1。

對設置進行測試

現在已經准備好對設置進行測試,並使用Kerberized SSH。

使用用戶名 sandeep 登錄到aixdce20.in.ibm.com(SSH 客戶端)。

使用kinit命令獲得 sandeep 的有效 Kerberos 憑據。

使用ssh 登錄到運行 SSH服務器的 aixdce16.in.ibm.com上。

下面的清單2 顯示了aixdce20.in.ibm.com上執行的命令序列,它將建立到 aixdce16.in.ibm.com 的以 Kerberos 為身份驗證機制的安全 Shell,並且使用Microsoft Active Directory Server作為KDC。

清單2.顯示使用Kerberos 身份驗證的成功 ssh 的示例輸出

# hostname
aixdce20
# whoami
sandeep
# kinit sandeep
Password for [email protected]:
# klist
Ticket cache:  FILE:/var/krb5/security/creds/krb5cc_0
Default principal:  [email protected]
Valid starting   Expires      Service principal
03/27/06 17:40:28 03/28/06 03:40:34  krbtgt/[email protected]
    Renew until 03/28/06 17:40:28
# ssh aixdce16.in.ibm.com
*******************************************************************************
*                                        *
*                                        *
* Welcome to AIX Version 5.3!                        *
*                                        *
*                                        *
* Please see the README file in /usr/lpp/bos for information pertinent to  *
* this release of the AIX Operating System.*
*                                       *
*                                       *
*******************************************************************************
$ hostname
aixdce16
$ whoami
sandeep
$ pwd
/home/sandeep
$ exit
Connection to aixdce16.in.ibm.com closed.
# hostname
aixdce20
# klist
Ticket cache: FILE:/var/krb5/security/creds/krb5cc_0
Default principal:  [email protected]

您已經從KDC 獲得了主體名 sandeep 的有效憑據,所以 讓我們來嘗試以主體 root 用戶進行登錄,如清單3 所示。

清單3.顯示 root 用戶的失敗 ssh 的 示例輸出

#ssh -v [email protected]
OpenSSH_3.8.1p1, OpenSSL 0.9.6m 17 Mar 2004
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to aixdce16.in.ibm.com [9.182.192.116] port 22.
debug1: Connection established.
..
..
..
debug1: Next authentication method: password
[email protected]'s password:
Connection closed by 9.182.192.116

調試信息 Connection established 表示,盡管 root 用戶可以使用主體 sandeep 的憑據進行成功的身份驗證,但是授權將失敗,即使指定了正確的密碼。這是因為Kerberos 發 現主體 [email protected] 不允許以 root 用戶來訪問。通過在 aixdce16.in.ibm.com:~root/.k5login中創建一個文件並在其中添加 sandeep主體,可以授權 root 用戶 使用sandeep主體。

因為.k5login文件覆蓋了缺省的授權規則,所以 root 用戶還需要在其中放置 自己的主體,否則它將無法使用主體進行登錄。下面的清單4 顯示了aixdce16.in.ibm.com上 root 用戶 的 home 目錄中的 .k5login文件的內容。

清單4.顯示 root 用戶的 home 目錄中的 .k5login文 件內容的示例輸出

# hostname
aixdce16
# cat .k5login
[email protected]
[email protected]

在創建了該文件 之後,root 用戶應該可以使用sandeep 的憑據成功地登錄了。

清單5.顯示 root 用戶使用 sandeep 憑據的成功 ssh 的示例輸出

$klist
Ticket cache:  FILE:/var/krb5/security/creds/krb5cc_204
Default principal:  [email protected]
Valid starting   Expires      Service principal
04/13/06 19:41:56 04/14/06 05:37:50 krbtgt/[email protected]
    Renew until 04/14/06 19:41:56
$ssh [email protected]
*******************************************************************************
*                                        *
*                                        *
* Welcome to AIX Version 5.3!                        *
*                                        *
*                                        *
* Please see the README file in /usr/lpp/bos for information pertinent to  *
* this release of the AIX Operating System.*
*                                       *
*                                       *
*******************************************************************************
#

結束語

本文介紹了管理員如何能夠充分地利用使用Microsoft Active Directory Server作為KDC 的AIX Version 5.3 系統中的 Kerberized OpenSSH。如果您的環境並沒有使 用Microsoft Active Directory Server,並且您希望在AIX Version 5.3 系統中使用Kerberized OpenSSH,那麼我們推薦您在其中一台 AIX 系統中安裝並配置IBM NAS Version 1.4 Server,並將它作為 KDC。

Copyright © Linux教程網 All Rights Reserved