i am trying to make bash script who read .ssh/config file and connect to hosts who only uses IdentityFile or ssh key, and run commands on remote servers. So problem is that config file contain hosts who don't use IdentityFile and connect via passwords. How to grep explicitly Host and IdentityFile blocks in file and discard others? I've make already script that connect to all hosts in file with for loop, but that is not what i want 100 %. Thank you. My .ssh/config file looks like this:
Host centos7-mp1
Hostname 192.168.89.102
user root
IdentityFile /root/.ssh/keys/id_rsa_passwordless
Host centos6-mp2
Hostname 192.168.89.103
user root
IdentityFile /root/.ssh/keys/id_rsa_passwordless
Host centosvm-test
Hostname 192.168.56.233
user test