SSH Sessions only open successfully if nodename == hostname
Description
While trying to SSH into my tailscale nodes via the Headplane UI, I noticed different behaviour for some nodes. While some where successful right from the start, some failed with errors like:
"Failed to connect to SSH sessionDial error: lookup ubuntu on [::1]:53: write udp 127.0.0.1:8->[::1]:53: write: Connection reset by peer"
("ubuntu" is my hostname)
This lead me to a lookup issue which couldnt be resolved by DNS settings.
Then I noticed that I changed the name of the node in the UI (from "ubuntu" to "vps") and reverted it back to the hostname of the node itself. The SSH Sessions was successfull immediately.
Steps to reproduce:
Change name of an SSH-enabled Tailscale node to an arbitrary name (only letters in my case).
Try SSHing via the UI. -> "Failed to connect to SSH sessionDial error: lookup
Headplane Version
0.6.1
Headscale Version
0.27
Oh my goodness this was the issue! So connecting to the node name and not the hostname is the correct behavior?
I haven't looked into the full backend code, but I guess it must be a name that is resolvable in the tailnet - which is the case for the node name but not the hostname (as they are not unique and can overlap between nodes).
A simple rewrite of the SSH URL "https://example.com/admin/ssh?hostname=NODENAME&username=USERNAME" resulted in "Node with hostname NODENAME not found" so I guess there must be more to it
having nodename = hostname always gets me a successful connection. This is fine in my setup but for larger ones I guess this is critical
Maybe I can do some sort of mapping and resolve it directly by IP, which should be possible anyways since I have access to the internal Tailnet IPs.
Try 0.7.0-beta.2, it resolves nodes via their IP address before connecting.