Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring Port directive from SSH config #1116

Closed
mhtr opened this issue Oct 23, 2024 · 0 comments · Fixed by #1117
Closed

Ignoring Port directive from SSH config #1116

mhtr opened this issue Oct 23, 2024 · 0 comments · Fixed by #1117

Comments

@mhtr
Copy link

mhtr commented Oct 23, 2024

System Information

OS

MacOS 15.0.1

Terraform version

terraform -v
Terraform v1.9.2
on darwin_arm64

Provider and libvirt versions

terraform-provider-libvirt -version
0.8.1

Description of Issue/Question

Unfortunately it ignores the settings in ~/.ssh/config that concern the Port directive. For the bastion node and for the host a custom port is specified, but the connection still goes to port 22.

Host <bastion_ip>
  Port 12345
  User username

Host <libvirt_host>
 Port 12345
 User username
 ProxyJump <bastion_ip>

Error:
Error: failed to connect: failed to connect to bastion host '<bastion_ip>': failed to connect to remote host '<bastion_ip>': dial tcp <bastion_ip>:22: connect: connection refused

If I don't use bastion and specify port in uri like this:

provider "libvirt" {
    uri = "qemu+ssh://username@<libvirt_host>:12345/system"
}

I get an error:
Error: failed to connect: failed to connect to remote host '<libvirt_host>:12345': dial tcp: lookup <libvirt_host>:12345: no such host

dmacvicar pushed a commit that referenced this issue Feb 28, 2025
* add per connection Port override check

* add log output to track what was done

* update port configuration precedence to something more sensisble

* remove code-golf'ing and make it more readable

* as per net/url, the .Host member can contain the portname

this will throw off the ssh_config lookups as the target will be incorrectly
given the server:port string instead of simply server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant