listen address: 0.0.0.0:2022 doesn't listen on tcp4, only tpc6
Opened this issue · 1 comments
erjoalgo commented
Not sure what has changed but by default my sshesame instance is only listening on ipv6 despite being configured with a listen address of 0.0.0.0:2022
:
# using listen_address: 127.0.0.1:2022
Sep 24 23:42:53 my-hostname sshesame[1950846]: INFO 2023/09/24 23:42:53 Listening on 127.0.0.1:2022
Sep 24 23:43:26 my-hostname systemd[1]: Stopping sshesame.service - sshesame...
Sep 24 23:43:26 my-hostname systemd[1]: sshesame.service: Deactivated successfully.
Sep 24 23:43:26 my-hostname systemd[1]: Stopped sshesame.service - sshesame.
Sep 24 23:43:26 my-hostname systemd[1]: Started sshesame.service - sshesame.
Sep 24 23:43:26 my-hostname sshesame[1951085]: INFO 2023/09/24 23:43:26 No host keys configured, using keys at "/home/USER/.local/share/sshesame"
# using listen_address: 0.0.0.0:2022
Sep 24 23:43:26 my-hostname sshesame[1951085]: INFO 2023/09/24 23:43:26 Listening on [::]:2022
go version
go version go1.20.7 linux/amd64
sshesame@v0.0.27/
erjoalgo commented
I modified github.com/jaksi/sshutils@v0.0.11/conn.go
to use tcp4
instead of tcp
and now the service is listening on the intended address, 0.0.0.0:2022
:
l, err := net.Listen("tcp4", address)
Not sure if there has been a change in go to default to ipv6
, the go contributor's comment in the bug below appears to suggest that using net: Listen("tcp", "0.0.0.0:1234")
would bind to both ipv4 and ipv6 addresses, but on my system nothing was listening on ipv4: