Bug 2578 - -W should honor -4 and -b
Summary: -W should honor -4 and -b
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 7.2p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-01 00:34 AEST by Marc 'Zugschlus' Haber
Modified: 2021-04-16 20:29 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc 'Zugschlus' Haber 2016-06-01 00:34:34 AEST
Hi,

ssh -W should honor -4 and -b options given on the same command line.

In practice, ssh -4 -W host:port will use IPv6 if host has an AAAA and an A record, and ssh -b valid.ipv4.address -W host:port will give "address family not supported" error if host has an AAAA and an A record.

Greetings
Marc
Comment 1 Darren Tucker 2016-06-01 10:37:48 AEST
(In reply to Marc 'Zugschlus' Haber from comment #0)
> ssh -W should honor -4 and -b options given on the same command line.

It does.  They apply to the connection from the client to the server as they always do.

$ ifconfig enp5s0
enp5s0: [...] inet 192.168.32.1

$ ssh -b 192.168.32.1 -4 -W server:22 server
SSH-2.0-OpenSSH_7.2

$ ssh -b 192.168.32.2 -4 -W server:22 server
bind: 192.168.32.2: Cannot assign requested address
ssh: connect to host server port 22: Cannot assign requested address

> In practice, ssh -4 -W host:port will use IPv6 if host has an AAAA
> and an A record

The client sends the hostname to the server which then resolves it, so that's dependent on name resolution config on the server side.

> and ssh -b valid.ipv4.address -W host:port will
> give "address family not supported" error if host has an AAAA and an
> A record.

A valid IPv4 address on the server or the client?  It should be on the client.

Anyway, as to the enhancement request: we couldn't use -4/-6 or -b for this since they already have meaning in this case.

For the IPv4 or IPv6 cases you can already resolve the address on the client side and pass the address to connect to on the command line, eg:

$ ssh -4 -W "[fe80::5054:ff:fef6:2ea%vio0]:22" server
SSH-2.0-OpenSSH_7.2

We could potentially add something to the client to allow the resolution on the client side although I am not convinced it's worth doing.  What is your use case for it?

For the remote bindaddress case I don't think it's possible at all since there's nothing in the protocol message to specify a bind addresses for forward connections (see RFC4254 section 7.2).
Comment 2 Antenore Gatta 2021-04-16 20:29:45 AEST
(In reply to Darren Tucker from comment #1)
> For the remote bindaddress case I don't think it's possible at all
> since there's nothing in the protocol message to specify a bind
> addresses for forward connections (see RFC4254 section 7.2). 

Isn´t it ´string    originator IP address´ the bind address?

My use case is simpler than the one described by OP.

I have a JumpHost with 2 network interface, the default network interface is used only to connect to some specific servers, all the others uses the secondary network interfecase and I accomplish this with BindAddress in the ssh_config file.

Unfortunately this doesn´t work with ProxyCommand and ProxyJump.

Any alternatives to this if it cannot be implemented?

Thanks!