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

Is there a way to check if the ssh is open for business ? #42

Closed
afbjorklund opened this issue Sep 11, 2021 · 7 comments
Closed

Is there a way to check if the ssh is open for business ? #42

afbjorklund opened this issue Sep 11, 2021 · 7 comments

Comments

@afbjorklund
Copy link

Trying to dial the tunnel port, but it seems to be throwing errors and die ?

tcpproxy: for incoming conn [::1]50054, error dialing "192.168.127.2:22": connect tcp 192.168.127.2:22: connection was refused
tcpproxy: for incoming conn [::1]50053, error dialing "192.168.127.2:22": connect tcp 192.168.127.2:22: connection was refused
Error: exit status 255

I could hardcode the VM IP, just hoping that there was a better way to test.

@guillaumerose
Copy link
Contributor

You can think about the port forwarder like a nginx reverse proxy and the VM like a http backend.
The reverse proxy doesn't know the state of the backend without using it. This is why you get Bad Gateway and not connection refused when the backend is down.

The port on gvproxy is always opened and does its best. But if the ssh service of the VM is not ready, it can't do much.

@afbjorklund
Copy link
Author

afbjorklund commented Sep 13, 2021

But is there a way to "know" the IP address of the VM, so that one can check if port 22 is responding yet ?

Or should we just issue ssh commands in a loop until it responds, like how it was done in podman-machine ?

Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2podman...

@guillaumerose
Copy link
Contributor

Yes! You can know 2 things:

Which MAC addresses are connected to the switch with:

$ curl http://127.0.0.1:7777/cam | jq .   
{
  "5a:94:ef:e4:0c:ee": 0
}

5a:94:ef:e4:0c:ee is connected on the first port (0 is the index of the first connection).

Ask the DHCP to know which IP is attributed to which MAC address.

$ curl http://127.0.0.1:7777/leases | jq .
{
  "192.168.127.1": "5a:94:ef:e4:0c:dd",
  "192.168.127.2": "5a:94:ef:e4:0c:ee"
}

These 2 IP are handled by static lease defined in the code directly.

@afbjorklund
Copy link
Author

Originally I was just hoping to be able to call SSH without getting an error 😀

But glad to hear that there is a way out, maybe it will improve in the future...

@afbjorklund
Copy link
Author

@guillaumerose : so you might add a function, where one can query the (hard-coded) MAC address for the IP ?

        // Right now the mac address is hardcoded so that the host networking gives it a specific IP address.

@guillaumerose
Copy link
Contributor

Originally I was just hoping to be able to call SSH without getting an error 😀

Yeah no good solution sorry :/

where one can query the (hard-coded) MAC address for the IP ?

This API endpoint already exists. /leases, /cam, etc.
As long as the VM uses DHCP, it will show in DHCP leases (/leases). Otherwise, you will only get the MAC address in the CAM table of the switch (/cam).

@afbjorklund
Copy link
Author

Silly me, no use for the IP address since the network isn't reachable anyway. That's what the proxy / tunnel is for...

@afbjorklund afbjorklund closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
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

No branches or pull requests

2 participants