Edit the following file:
Sudo Nano /etc/iscsi/iscsid.conf
Remove the # from the following lines and update the username and password accordingly
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = inboundpassword
discovery.sendtargets.auth.authmethod = CHAP
discovery.sendtargets.auth.username = username
discovery.sendtargets.auth.password = inboundpassword
Now you can run a discovery scan
iscsiadm -m discovery -t st -p ip:port
example: iscsiadm -m discovery -t st -p 192.168.0.1:3260)
If successful you should get a response
192.168.0.1:3260,1 iqn.2010-03.com.example:test.vm
Now you can login to the target iqn
iscsiadm -m node -T target_iqn_name -p ipaddress -l
Example:
iscsiadm -m node -T iqn.2010-03.com.example:test.vm -p 192.168.0.1 -l
Here is if you want to login to all discovered LUNs
iscsiadm -m discovery -t st -l
The information is stored in the node database found in /var/lib/iscsi.
To log out of the target
iscsiadm -m node -T target_iqn_name -p ipaddress -u
example:
iscsiadm -m node -T iqn.2010-03.com.example:test.vm -p 192.168.0.1 -u
Then remove from the database so on a reboot it does not reconnect
iscsiadm -m node -T target_iqn_name -p ip address --op delete
example:
iscsiadm -m node -T iqn.2010-03.com.example:test.vm -p 192.168.0.1 --op delete
To logout of all targets
iscsiadm -m node -U all
References:
https://www.thegeekdiary.com/how-to-configure-iscsi-initiator-client-in-centos-rhel-7/
https://library.netapp.com/ecmdocs/ECMP1217221/html/GUID-826A3F69-420C-457B-AE35-91DFA7B3B7AB.html