Bug 2626 - ssh 172.10 resolves to ssh 172.0.0.10
Summary: ssh 172.10 resolves to ssh 172.0.0.10
Status: CLOSED INVALID
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 7.3p1
Hardware: 68k Mac OS X
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-18 14:51 AEDT by Raj Kishore Panigrahi
Modified: 2021-04-23 14:53 AEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raj Kishore Panigrahi 2016-10-18 14:51:57 AEDT
Hello Team,

I found something weird today, i tried to ssh into a box with the below command, instead of throwing an error it filled the middle to octet with zeros. 

Looks like ssh is greed and tries to left-pad everything with zero until it gets 4 octets. See the below two examples

1.
hostname $/usr/local/bin/ssh -v 172.10
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016
debug1: Reading configuration data /Users/name/.ssh/config
debug1: /Users/name/.ssh/config line 2: Applying options for *
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug1: Connecting to 172.10 [172.0.0.10] port 22.
^C
hostname $


2.
hostname $ssh -v 172
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/name/.ssh/config
debug1: /Users/name/.ssh/config line 2: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 172 [0.0.0.172] port 22.
debug1: connect to address 0.0.0.172 port 22: No route to host
ssh: connect to host 172 port 22: No route to host
Comment 1 Darren Tucker 2016-10-18 15:12:41 AEDT
This is a feature of gethostbyname and earlier gethostbyaddr interfaces: class.hostnum and the 32bit integer equivalent are deprecated but still valid representations of an IP address.

Compare:
$ telnet 172.10
Trying 172.0.0.10...

$ telnet 1.512
Trying 1.0.2.0...

$ perl -le 'print 2**31+1'
2147483649
$ telnet 2147483649
Trying 128.0.0.1...

If you really want something to complain about, try this:
$ telnet  172.010
Trying 172.0.0.8...

That all said, it's not something that OpenSSH has anything to do with.

Also: hardware=68k?  for real?
Comment 2 Darren Tucker 2016-10-18 15:14:45 AEDT
(In reply to Darren Tucker from comment #1)
> This is a feature of gethostbyname and earlier gethostbyaddr

err, those are both the earlier ones.  The current one is getaddrinfo.
Comment 3 Darren Tucker 2016-10-18 15:30:25 AEDT
Looks like this behaviour originated in inet_aton() in 4.2BSD.
https://en.wikipedia.org/wiki/Dot-decimal_notation
Comment 4 Damien Miller 2021-04-23 14:53:08 AEST
closing resolved bugs as of 8.6p1 release