owenthereal / upterm

Instant Terminal Sharing
https://upterm.dev
Apache License 2.0
829 stars 54 forks source link

Invalid entry added to known hosts #135

Open ww-daniel-mora opened 2 years ago

ww-daniel-mora commented 2 years ago

After running upterm an invalid entry is added to the known_hosts file. Attempting to run upterm later results in the following error:

FATA[0000] knownhosts: /Users/daniel/.ssh/known_hosts:4: address [2a09:8280:1::3:4b89]: missing port in address

OS: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64 Upterm: Upterm version v0.9.0 Removing the entry enables you to run upterm again. Manually adding port 22 to the address resolves the issue.

owenthereal commented 2 years ago

Would you mind sharing the known host line in /Users/daniel/.ssh/known_hosts:4? It's likely that you have an invalid host line that wasn't added by upterm and upterm complained about it when trying to write a new host line for the uptermd server

freswa commented 1 year ago

Same issue here, but the reported line is the one created by upterm: @cert-authority uptermd.upterm.dev,[2a09:8280:1::3:4b89] ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICiecex8Dq718eSe1CCLgLvDmI7AagvCtax7brPFWkh4

pacien commented 1 year ago

IPv6 addresses are added with brackets to avoid ambiguities, and OpenSSH mandates an explicit port with the bracketed syntax.

The issue is that golang.org/x/crypto/ssh/knownhosts.Normalize omits the port when it's the default one, even when adding brackets, which is not valid according to sshd(8) / "SSH_KNOWN_HOSTS FILE FORMAT".

Upstream issue: https://github.com/golang/go/issues/53463