Skip ssh config parsing when Net::OpenSSH backend is used
Net::OpenSSH backend just uses the OpenSSH binaries in the backgrond, so they should be able to transparently use any available ssh configuration like ~/.ssh/config.
So in that case, there's no need to try and parse the ssh configuration, but we should make sure it still works for other backend that might rely on it (like Net::SSH2).
From my experience this doesn't work because when rex creates the Net::OpenSSH object it uses the ip address in the constructor, not the hostname that i provide. This means none of my ~/.ssh/config will get picked up by the ssh binary.
For example, with the following ~/.ssh/config:
Host myhost
HostName 123.456.789
ForwardAgent yes
calling rex -H myhost some_task will not get forwardagent=yes turned on.
The worst (but easiest) workaround is to put the ip address in your /.ssh/config entry like so:
Host myhost 123.456.789
HostName 123.456.789
ForwardAgent yes
The next workaround would be to manually parse your ~/.ssh/config and call Rex::Config->set_openssh_opt in your Rexfile prior to the task running.
Is there a reason Rex resolves the ip address and uses it rather than using the hostname provided?
Currently Rex unconditionally tries to parse (a subset of) the ~/.ssh/config and sets some connection parameters accordingly. This is purely for historical reasons, as for a long time only Net::SSH2 was supported as an SSH backend (because that is supports running on Windows too via libssh2).
When Net::OpenSSH support was added, this unconditional preprocessing of the SSH config stayed in place, and has not been cleaned up yet. This issue is about "Rex should not try to be smart when Net::OpenSSH is in use, but we are not there yet".