Bash extract user for a particular host from ssh config file
You can use ssh
configuration test mode to parse the configuration file and return you the expected value:
ssh -G hostname | grep "^user "
This should work since openssh-6.8
.
As per 123's comment above:
var=$(awk '/^Host bloo$/{x=1}x&&/User/{print $2;exit}' ssh.conf)
That will assign value ABCDEF
to var.