[CentOS] working with multiple password protected iSCSI targets on one host

Tue Feb 15 16:11:50 UTC 2011
Santi Saez <santisaez at woop.es>

El 15/02/2011 14:54, Rudi Ahlers escribió:

Hi Rudi,

> How do I setup multiple password protected iSCSI targets on Linux?
>
> (..)
>
> But, now I need to mount another iSCSI target, from a different SAN
> that has a different username&  password than whan I have configured
> here for the one already mounted.
>
> How do I tell iscsiadm which CHAP settings to use with which iSCSI target?

I think there is not elegant way to do this.. I follow those steps:

1) Set discovery.sendtargets.{auth,password} in iscsid.conf for target-1 
+ restart iscsid service.

2) Set CHAP settings for target-1 + connect:

# iscsiadm -m node --targetname ${TARGETNAME1} -p ${PORTAL1} -o update 
-n node.session.auth.username -v ${USERNAME}
# iscsiadm -m node --targetname ${TARGETNAME1} -p ${PORTAL1} -o update 
-n node.session.auth.password -v ${PASSWORD}
# iscsiadm -m node --targetname ${TARGETNAME1} -p ${PORTAL1} -l

3) Disconnect from target-1:

# iscsiadm -m node --logoutall all

4) Set discovery.sendtargets.{auth,password} in iscsid.conf for target-2 
+ restart iscsid service.

5) Set CHAP settings for target-2 + connect:

# iscsiadm -m node --targetname ${TARGETNAME2} -p ${PORTAL2} -o update 
-n node.session.auth.username -v ${USERNAME}
# iscsiadm -m node --targetname ${TARGETNAME2} -p ${PORTAL2} -o update 
-n node.session.auth.password -v ${PASSWORD}
# iscsiadm -m node --targetname ${TARGETNAME2} -p ${PORTAL2} -l

It works! Now you can login/logout in both iSCSI targets:

# iscsiadm -m node --logoutall all
# iscsiadm -m node --loginall all

Cheers,

--
Santi Saez
http://woop.es