Comment 6 for bug 61414

Revision history for this message
Guillermo Pérez (bisho) wrote :

Binary package hint: openssh-client

When you try to make a ssh-tunnel with the -g option it doesn't work.

ssh -g -L 1433:remote_host:1433 root@another_host 'while true; do sleep 18000; done'

This should open local port 1433 and redirect the connection via a ssh tunel to "another_host". Then send from this machine to "remote_host". It was working perfectly in an old machine.

If you try using the -g option (allow remote conections on local port) it binds to 0.0.0.0 (all interfaces) on the machine, but dumps this error:

bind: Address already in use

And it's oppening and using the port but not forwarding connections. An strace shows that it's traying to open the socket ¿twice?:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(1433), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(33047), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
close(4) = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_INET6, sin6_port=htons(1433), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
listen(4, 128) = 0
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfb716b8) = -1 EINVAL (Invalid argument)
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfb716b8) = -1 EINVAL (Invalid argument)
fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(1433), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
write(2, "bind: Address already in use\r\n", 30) = 30

I solved out problem specifying the IP address to use for binding:

ssh -L LOCAL_IP:1433:remote_host:1433 root@another_host 'while true; do sleep 18000; done'

But the -g option should work anyway. I suppose it's a bug on ssh not just ubuntu but I can't check recent versions of other distros.