headplane icon indicating copy to clipboard operation
headplane copied to clipboard

SSH Sessions only open successfully if nodename == hostname

Open phil3741 opened this issue 1 year ago • 4 comments

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 on [::1]:53: write udp 127.0.0.1:8->[::1]:53: write: Connection reset by peer"

Headplane Version

0.6.1

Headscale Version

0.27

phil3741 avatar Nov 04 '25 17:11 phil3741

Oh my goodness this was the issue! So connecting to the node name and not the hostname is the correct behavior?

tale avatar Nov 04 '25 17:11 tale

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

phil3741 avatar Nov 04 '25 19:11 phil3741

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.

tale avatar Nov 16 '25 21:11 tale

Try 0.7.0-beta.2, it resolves nodes via their IP address before connecting.

tale avatar Apr 11 '26 15:04 tale