iSCSI服務(wù)器CHAP雙向認(rèn)證配置及創(chuàng)建步驟
一 iSCSI和CHAP介紹
1.1 iSCSI 磁盤(pán)
- iSCSI后端存儲(chǔ)支持多種設(shè)備類(lèi)型,主要有:
- 文件
- 單一分區(qū)(partition)
1.磁盤(pán)
2.數(shù)組
3.RAID
LVM 本手冊(cè)建議以裸磁盤(pán)vdb作為示例,其他類(lèi)型配置參考《002.iSCSI服務(wù)端多類(lèi)型配置》。 同時(shí)本手冊(cè)基于生產(chǎn)環(huán)境安全考慮,結(jié)合CHAP進(jìn)行配置認(rèn)證。
1.2 CHAP介紹
基于IP的認(rèn)證比較粗糙,對(duì)于安全性要求高的環(huán)境來(lái)說(shuō),使用CHAP認(rèn)證其安全性更有保障。
CHAP(Challenge-Handshake Authentication Protocol),稱(chēng)為挑戰(zhàn)式握手認(rèn)證協(xié)議,它是雙向認(rèn)證,當(dāng)然也支持單向認(rèn)證。
對(duì)于iscsi而言,在CHAP認(rèn)證的機(jī)制上有兩種方式:initiator authentication和target authentication。
1.2.1 initiator authentication認(rèn)證
在initiator嘗試連接到一個(gè)target的時(shí)候,initator需要提供一個(gè)用戶(hù)名和密碼給target被target進(jìn)行認(rèn)證。
也就是說(shuō)initiator需要被target認(rèn)證,它向target端提供的賬號(hào)和密碼是target端指定的。
這個(gè)賬號(hào)和密碼對(duì)于target來(lái)說(shuō)是流入的賬號(hào)和密碼,用incoming表示。
稱(chēng)呼這個(gè)賬號(hào)和密碼為:incoming賬號(hào)和incoming密碼。
即,incoming賬號(hào)是initiator端提供給target端,被target端認(rèn)證的賬號(hào)。
1.2.2 target authentication認(rèn)證
在initiator嘗試連接到一個(gè)target的時(shí)候,target有時(shí)也需要被initiator認(rèn)證,以確保該target是合法而非偽裝的target,這就要求target提供一個(gè)用戶(hù)名和密碼給initiator被initiator進(jìn)行認(rèn)證。
target向initiator提供的賬號(hào)和密碼對(duì)于target而言是流出的,所以稱(chēng)之為outgoing。
稱(chēng)呼這個(gè)賬號(hào)和密碼為:outgoing賬號(hào)和outgoing密碼。
而對(duì)于initiator而言是incoming的,所以在initiator配置文件中稱(chēng)為in。
也就是說(shuō)outgoing賬號(hào)是target端提供給initiator端,被initiator認(rèn)證的賬號(hào),但盡管如此,這個(gè)賬號(hào)和密碼還是在target端創(chuàng)建和綁定的。
1.2.3 單/雙向認(rèn)證
兩種認(rèn)證方式是有層次順序的。
一般來(lái)說(shuō),有認(rèn)證需求的時(shí)候都是服務(wù)器驗(yàn)證客戶(hù)端是否有權(quán)限,iscsi也一樣。
initiator authentication可以單獨(dú)存在,它可以在沒(méi)有target authentication的情況下應(yīng)用,這時(shí)候的CHAP認(rèn)證就是單向認(rèn)證(target認(rèn)證initiator的合法性)。
但target authentication只有在initiator authentication的基礎(chǔ)上才能進(jìn)行。也就是說(shuō)target認(rèn)證和initiator認(rèn)證必須同時(shí)存在才可以。即initiator和target需要相互認(rèn)證實(shí)現(xiàn)雙向CHAP認(rèn)證。
注意:發(fā)現(xiàn)認(rèn)證和登錄認(rèn)證都支持單/雙向認(rèn)證。
二 iSCSI創(chuàng)建步驟
- 建立用于共享的磁盤(pán)
- 創(chuàng)建后備磁盤(pán)
- 創(chuàng)建相應(yīng)的IQN
- 創(chuàng)建相應(yīng)的規(guī)則
- 為后備磁盤(pán)創(chuàng)建LUN
- 創(chuàng)建雙向認(rèn)證賬號(hào)和密碼
- 指定偵聽(tīng)的IP和端口
- 檢查并保存配置
- 防火墻規(guī)則開(kāi)放
- 服務(wù)(開(kāi)機(jī))啟動(dòng)
三 前置準(zhǔn)備
3.1 環(huán)境準(zhǔn)備
主機(jī)名 | IP | 備注 |
iscsi | 172.24.8.72 | iSCSI服務(wù)器 |
client | 172.24.8.71 | iSCSI客戶(hù)端 |
3.2 查看裸磁盤(pán)
[root@iscsi ~]# fdisk -l Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
四 創(chuàng)建后備存儲(chǔ)
4.1 安裝相關(guān)軟件
[root@iscsi ~]# yum -y install targetcli
4.2 交互設(shè)置
[root@system1 ~]# targetcli #進(jìn)入targetcli交互配置視圖
- block:定義的塊設(shè)備,磁盤(pán)驅(qū)動(dòng)器、磁盤(pán)分區(qū)、LVM等
- fileio:創(chuàng)建的指定大小的文件,如dd if=/dev/zero of=……所創(chuàng)建
- pscsi:物理SCSI,通常不采用此類(lèi)型
- ramdisk:在內(nèi)存中創(chuàng)建的一個(gè)指定大小ramdisk設(shè)備
Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> /backstores/block create block1 /dev/sdb #將裸磁盤(pán)創(chuàng)建為后備盤(pán) /> /iscsi create wwn=iqn.2022-11.com.imxhy:disk01 #創(chuàng)建符合名稱(chēng)的IQN /> /iscsi/iqn.2022-11.com.imxhy:disk01/tpg1/luns create /backstores/block/block1 #將創(chuàng)建的后備磁盤(pán)block1創(chuàng)建一個(gè)LUN /> /iscsi/iqn.2022-11.com.imxhy:disk01/tpg1/acls create iqn.2021-11.com.imxhy:client #只允許配置iqn.2021-11.com.imxhy:client的key才能使用此iSCSI提供的磁盤(pán)服務(wù) /> /iscsi/iqn.2021-11.com.imxhy:disk01/tpg1/portals/ delete 0.0.0.0 3260 #刪除默認(rèn)的全部偵聽(tīng) /> /iscsi/iqn.2022-11.com.imxhy:disk01/tpg1/portals/ create 172.24.8.72 3260 #指定本地用于偵聽(tīng)客戶(hù)端連接的IP /> /iscsi/ set discovery_auth enable=1 userid=discover password=discoverps #選配,本實(shí)驗(yàn)增加discovery的認(rèn)證 /> /iscsi/ get discovery_auth DISCOVERY_AUTH CONFIG GROUP =========================== enable=True ----------- The enable discovery_auth parameter. mutual_password= ---------------- The mutual_password discovery_auth parameter. mutual_userid= -------------- The mutual_userid discovery_auth parameter. password=discoverps ------------------- The password discovery_auth parameter. userid=discover --------------- The userid discovery_auth parameter. /> /iscsi/iqn.2022-11.com.imxhy:disk01/tpg1/acls/iqn.2021-11.com.imxhy:client/ set auth userid=user01 password=u1pass mutual_userid=muser01 mutual_password=m1pass /> /iscsi/iqn.2022-11.com.imxhy:disk01/tpg1/acls/iqn.2021-11.com.imxhy:client/ get auth #查看配置 AUTH CONFIG GROUP ================= mutual_password=m1pass ---------------------- The mutual_password auth parameter. mutual_userid=muser01 --------------------- The mutual_userid auth parameter. password=u1pass The password auth parameter. userid=user01 ------------- The userid auth parameter. /> ls / o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 1] | | o- block1 ........................................................................... [/dev/sdb (1.0GiB) write-thru activated] | | o- alua ................................................................................................... [ALUA Groups: 1] | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized] | o- fileio ................................................................................................. [Storage Objects: 0] | o- pscsi .................................................................................................. [Storage Objects: 0] | o- ramdisk ................................................................................................ [Storage Objects: 0] o- iscsi ........................................................................................... [1-way disc auth, Targets: 1] | o- iqn.2022-11.com.imxhy:disk01 ...................................................................................... [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 1] | | o- iqn.2021-11.com.imxhy:client ......................................................................... [Mapped LUNs: 1] | | o- mapped_lun0 ................................................................................ [lun0 block/block1 (rw)] | o- luns .......................................................................................................... [LUNs: 1] | | o- lun0 ..................................................................... [block/block1 (/dev/sdb) (default_tg_pt_gp)] | o- portals .................................................................................................... [Portals: 1] | o- 172.24.8.72:3260 ................................................................................................. [OK] o- loopback ......................................................................................................... [Targets: 0] /> exit
提示:如上操作:
1:創(chuàng)建的ACL將分配到每個(gè)LUN。
2:創(chuàng)建LUN必須在TPG下。
3:若不指定端口將采用默認(rèn)端口3260
4:若不指定IP,將允許服務(wù)器上定義的所有網(wǎng)絡(luò)接口上的連接
5:創(chuàng)建LUN必須在TPG下
五 防火墻開(kāi)放
[root@iscsi ~]# firewall-cmd --add-port=3260/tcp --permanent #防火墻添加iSCSI的端口 [root@iscsi ~]# firewall-cmd --add-service=iscsi-target --permanent #防火墻放通iSCSI target服務(wù) [root@iscsi ~]# firewall-cmd --reload
六 開(kāi)啟服務(wù)
[root@iscsi ~]# systemctl enable target --now
七 客戶(hù)端配置
[root@client ~]# yum -y install iscsi-initiator-utils #安裝客戶(hù)端 [root@client ~]# vim /etc/iscsi/initiatorname.iscsi #配置CHAP認(rèn)證 InitiatorName=iqn.2021-11.com.imxhy:client [root@client ~]# vim /etc/iscsi/iscsid.conf …… node.session.auth.authmethod = CHAP node.session.auth.username = user01 node.session.auth.password = u1pass node.session.auth.username_in = muser01 node.session.auth.password_in = m1pass discovery.sendtargets.auth.authmethod = CHAP discovery.sendtargets.auth.username = discover discovery.sendtargets.auth.password = discoverps [root@client ~]# systemctl restart iscsid
八 客戶(hù)端登錄
8.1 發(fā)現(xiàn)目標(biāo)
[root@client ~]# iscsiadm -m discovery -t sendtargets -p 172.24.8.72 ? ? ? ? ? ? ? ? ? ? #發(fā)現(xiàn)目標(biāo) 172.24.8.72:3260,1 iqn.2022-11.com.imxhy:disk01
8.2 登錄目標(biāo)
[root@client ~]# iscsiadm -m node -T iqn.2022-11.com.imxhy:disk01 -p 172.24.8.72 -l ? ? ? ? ? #登錄目標(biāo)
8.3 查詢(xún)信息
[root@client ~]# iscsiadm -m session -o show tcp: [23] 172.24.8.72:3260,1 iqn.2022-11.com.imxhy:disk01 (non-flash) [root@client ~]# iscsiadm -m session -P 3 ? ? ? ?#查詢(xún)信息 iSCSI Transport Class version 2.0-870 version 6.2.0.874-22 Target: iqn.2022-11.com.imxhy:disk01 (non-flash) ? ? ? ? Current Portal: 172.24.8.72:3260,1 ? ? ? ? Persistent Portal: 172.24.8.72:3260,1 ? ? ? ? ? ? ? ? ********** ? ? ? ? ? ? ? ? Interface: ? ? ? ? ? ? ? ? Iface Name: default ? ? ? ? ? ? ? ? Iface Transport: tcp ? ? ? ? ? ? ? ? Iface Initiatorname: iqn.2021-11.com.imxhy:client ? ? ? ? ? ? ? ? Iface IPaddress: 172.24.8.71 ? ? ? ? ? ? ? ? Iface HWaddress: <empty> ? ? ? ? ? ? ? ? Iface Netdev: <empty> ? ? ? ? ? ? ? ? SID: 1 ? ? ? ? ? ? ? ? iSCSI Connection State: LOGGED IN ? ? ? ? ? ? ? ? iSCSI Session State: LOGGED_IN ? ? ? ? ? ? ? ? Internal iscsid Session State: NO CHANGE ? ? ? ? ? ? ? ? ********* ? ? ? ? ? ? ? ? Timeouts: ? ? ? ? ? ? ? ? Recovery Timeout: 120 ? ? ? ? ? ? ? ? Target Reset Timeout: 30 ? ? ? ? ? ? ? ? LUN Reset Timeout: 30 ? ? ? ? ? ? ? ? Abort Timeout: 15 ? ? ? ? ? ? ? ? ***** ? ? ? ? ? ? ? ? CHAP: ? ? ? ? ? ? ? ? username: user01 ? ? ? ? ? ? ? ? password: ******** ? ? ? ? ? ? ? ? username_in: muser01 ? ? ? ? ? ? ? ? password_in: ******** ? ? ? ? ? ? ? ? ************************ ? ? ? ? ? ? ? ? Negotiated iSCSI params: ? ? ? ? ? ? ? ? HeaderDigest: None ? ? ? ? ? ? ? ? DataDigest: None ? ? ? ? ? ? ? ? MaxRecvDataSegmentLength: 262144 ? ? ? ? ? ? ? ? MaxXmitDataSegmentLength: 262144 ? ? ? ? ? ? ? ? FirstBurstLength: 65536 ? ? ? ? ? ? ? ? MaxBurstLength: 262144 ? ? ? ? ? ? ? ? ImmediateData: Yes ? ? ? ? ? ? ? ? InitialR2T: Yes ? ? ? ? ? ? ? ? MaxOutstandingR2T: 1 ? ? ? ? ? ? ? ? Attached SCSI devices: ? ? ? ? ? ? ? ? Host Number: 3 ?State: running ? ? ? ? ? ? ? ? scsi3 Channel 00 Id 0 Lun: 0 ? ? ? ? ? ? ? ? ? ? ? ? Attached scsi disk sdb ? ? ? ? ?State: running [root@client ~]# iscsiadm -m node -o show # BEGIN RECORD 6.2.0.874-22 node.name = iqn.2022-11.com.imxhy:disk01 node.tpgt = 1 node.startup = automatic …… iface.transport_name = tcp node.discovery_address = 172.24.8.72 node.discovery_port = 3260 node.discovery_type = send_targets node.session.initial_cmdsn = 0 node.session.initial_login_retry_max = 8 node.session.xmit_thread_priority = -20 node.session.cmds_max = 128 node.session.queue_depth = 32 node.session.nr_sessions = 1 node.session.auth.authmethod = CHAP node.session.auth.username = user01 node.session.auth.password = ******** node.session.auth.username_in = muser01 node.session.auth.password_in = ******** node.session.scan = auto node.conn[0].address = 172.24.8.72 node.conn[0].port = 3260 # END RECORD [root@client ~]# fdisk -l ? ? ? ? ? ? ? ?#發(fā)現(xiàn)的iSCSI服務(wù)器三個(gè)共享
九 格式化并掛載
9.1 格式化并掛載
注意:
1:此時(shí)能當(dāng)做本地磁盤(pán)使用,分區(qū)格式化等操作;
2:可使用RAID或LVM來(lái)進(jìn)行操作,LVM的可在之后格式化LV。
[root@client ~]# mkfs.ext4 /dev/sdb ? ? ? ? ? ? ?#格式化相關(guān)iSCSI磁盤(pán) [root@client ~]# mkdir -p /iscsdisk/sdb01 ? ? ? ? ? #創(chuàng)建用于掛載sdd磁盤(pán)的掛載點(diǎn) ? ? ? ? [root@client ~]# mkdir -p /iscsdisk/lv01 ? ? ? ? ? ?#創(chuàng)建用于掛載LVM分區(qū)的掛載點(diǎn) [root@client ~]# mount /dev/sdb /iscsdisk/sdb01/ ? ? ?#可直接掛載 [root@client ~]# vi /etc/fstab ? ? ? ? ? ? ? ? ? #自動(dòng)掛載 …… /dev/sdb /iscsdisk/lv01 ? ?ext4 ? ?defaults ? ?0 0
到此這篇關(guān)于iSCSI服務(wù)器CHAP雙向認(rèn)證配置的文章就介紹到這了,更多相關(guān)iSCSI服務(wù)器CHAP內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。