Win32-OpenSSH
Win32-OpenSSH copied to clipboard
Setting the source address with -b does not work
"OpenSSH for Windows" version
8.0.0.0
Server OperatingSystem N/A (Linux)
Client OperatingSystem Windows 10 v1809 Windows 10 v1903 18932.1000 (insider's preview)
What is failing
The -b
argument to select a source address does not work and says "Invalid argument". The -B
argument to select a source interface reports it is not supported, which is fine.
Example command:
ssh -vvv -b 192.168.1.4 192.168.1.1
It does not matter if there exists a server at the remote end. The error happens before any packets are sent.
Expected output Working example from Ubuntu via WSL:
OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.1.1" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
Actual output
OpenSSH_for_Windows_8.0p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\bob.rao/.ssh/config
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 192.168.1.1 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: ssh_create_socket: bound to 192.168.1.4
debug3: connectex - ERROR: bind failed :10022, io:00000159E2A4FB60
debug1: connect to address 192.168.1.1 port 22: Invalid argument
ssh: connect to host 192.168.1.1 port 22: Invalid argument
Were you able to resolve this? I'm encountering the exact same issue. Best I can tell it is an issue with the WSAEINVAL error of the bind function:
"An invalid argument was supplied.This error is returned of the socket s is already bound to an address."
https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind
I don't believe I ever resolved this - I ended up using a Debian VM with bridged networking in the meantime.
Any news on this?
@tgauth - Please look into this.
"An invalid argument was supplied.This error is returned of the socket s is already bound to an address."
https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind
When a bind address is provided, we try to bind twice. First, in ssh_create_socket and then again, in socketio_connectex, when the error gets thrown.
When a bind address is not provided, ssh_create_socket returns before binding, so socketio_connectex does not throw an error.
"An invalid argument was supplied.This error is returned of the socket s is already bound to an address." https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind
When a bind address is provided, we try to bind twice. First, in ssh_create_socket and then again, in socketio_connectex, when the error gets thrown.
When a bind address is not provided, ssh_create_socket returns before binding, so socketio_connectex does not throw an error.
https://github.com/PowerShell/openssh-portable/pull/599
Hi. Looks like BindInterface
or -B
is still not supported? If that's intended for the time being, can we add a notice in this wiki page? Thanks!
(Forgive me for continuing this thread. It seems the most relevant place to post it.)
@whentojump, what OpenSSH version are you using? The latest GitHub release or the Windows in-box version?
Hi, tgauth. Thanks for your quick response!
I'm using the binary from the zip archive (OpenSSH-Win64.zip
) on GitHub.
Behavior I'm seeing (same on two of my Windows 10 boxes):
$ .\ssh.exe -V
OpenSSH_for_Windows_9.2p1, LibreSSL 3.7.2
$ .\ssh.exe -T -b 192.168.1.100 [email protected]
Hi whentojump! You've successfully authenticated, but GitHub does not provide shell access.
$ .\ssh.exe -T -B <intface-name> [email protected]
BindInterface not supported on this platform.
ssh_create_socket: getnameinfo failed: An address incompatible with the requested protocol was used.
ssh: connect to host github.com port 22: failure
Only capital -B
(BindInterface
) is not working. Their equivalents on Linux both work fine.
Any hint? Thank you!
@whentojump ah so, -B
and -b
are two different parameters for ssh. This issue was closed since -b support was added, however -B
is still not supported. I updated the wiki page to indicate this, as you suggested.
Feel free to open a new issue detailing the use case for -B
.
Yeah, that's what I meant. Thank you!