rgzr / sshtun

Go package to create SSH tunnels
MIT License
86 stars 12 forks source link

SSH Authentication failure does not result in an error #6

Closed bpx279 closed 4 years ago

bpx279 commented 4 years ago

Problem If a user does not have proper authorization to an SSH host, the sshtun.StateStarted is still being reported as if the connection was successful.

There is no error reported by sshtun and trying to access the forwarded port results in a debug log message similar to "Accepted connection from 127.0.0.1:6753" but the forwarded port never responds.

Expected Result sshtun should either return an error upon calling sshtun.Start if the authentication is unsuccessful or at the very least not report sshtun.StateStarted.

bpx279 commented 4 years ago

Upon further inspection, it seems that the Mutex is never unlocked before calling tun.errStarted in the forward function. Calling tun.Unlock before tun.errStarted and then tun.Lock after, the behavior is correct.