• [deleted]

env
jean-michel@ bidule ~ % hostname
bidule

jean-michel@ bidule ~ % cat /etc/hostname
bidule

jean-michel@ bidule [1] ~ % cat /etc/66/boot.conf | grep HOSTNAME
# # Set the HOSTNAME.
HOSTNAME=bidule

Issue
Use $(hostname) or $(hostname -f) as value for hostname.

jean-michel@ bidule ~ % ssh-keyscan $(hostname)
getaddrinfo bidule: Device or resource busy
getaddrinfo bidule: Device or resource busy
getaddrinfo bidule: Device or resource busy

jean-michel@ bidule [1] ~ % ssh-keyscan $(hostname -f)
getaddrinfo bidule: Device or resource busy
getaddrinfo bidule: Device or resource busy
getaddrinfo bidule: Device or resource busy

Expected
Print the rsa host key for machine hostname

Info
To be clear it's not an ssh-keyscan issue but something else on the system that I'm not able to identify.
check /etc/hosts
check /etc/nsswitch.conf
what return : ssh $(hostname) ?
  • [deleted]

/etc/nsswitch.conf
hosts: files resolve [!UNAVAIL=return] dns myhostname
/etc/hosts
127.0.0.1 localhost
::1 localhost
Obviously my hostname is not resolvable. ( However this configuration is used on systemd distro like Mageia for example and ssh-keyscan $(hostname) works as expected. that mean something in systemd make the thing works. )

So how did I come to the conclusion of applying this configuration in /etc/hosts.?
Well since HOSTNAME can be set in boot.conf, so 66 will be able to manage hostname and take care of resolving my hostname. But it seems that it is not true. In this case what the purpose of the HOSTNAME in boot.conf ? What exactly the boot does with this value and the HOSTNAME variable?
  • [deleted]

First case:

env

/etc/hostname
bidule
/etc/hosts
127.0.0.1 localhost.localdomain localhost
result
 jean-michel@ bidule ~ % hostname
bidule 
 jean-michel@ bidule ~ % hostname -d
(none) 
 jean-michel@ bidule ~ % hostname -f
bidule 
 jean-michel@ bidule ~ % hostname -s
bidule 
Second case:

env

/etc/hostname
bidule

/etc/hosts
127.0.0.1 localhost.localdomain localhost bidule
result
 jean-michel@ bidule ~ % hostname
bidule 
 jean-michel@ bidule ~ % hostname -d
localdomain 
 jean-michel@ bidule ~ % hostname -f
localhost.localdomain 
 jean-michel@ bidule ~ % hostname -s
localhost 
Third case:

env

/etc/hostname
bidule
/etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.1.1 bidule.family.home bidule
result
 jean-michel@ bidule ~ % hostname
bidule 
 jean-michel@ bidule ~ % hostname -d
family.home 
 jean-michel@ bidule ~ % hostname -f
bidule.family.home 
 jean-michel@ bidule ~ % hostname -s
bidule 
The question now is which one is correct?

My own opinion the /etc/hosts with a minimal entries for ipv4 and ipv6
127.0.0.1 localhost
::1 localhost
Hostname resolution and everything else should be done outside of this file. I guess that's what systemd does.
according to the man page of hosts (https://jlk.fjfi.cvut.cz/arch/manpages/man/hosts.5),my /etc/hosts on my system is:
127.0.0.1	localhost
::1		localhost
127.0.0.1	S6.localdomain	S6
with this configuration , i haven't any trouble with ssh. the command ssh $(hostname) return me:
ssh $(hostname)
ssh: connect to host s6 port 22: Connection refused
which is the expected behavior. As you can see the hostname is found properly.

To answer you about the hostname configuration at boot time: the system-hostname service will parse and get the $HOSTNAME value and set it on the kernel side calling the sethostname() function. But i just realized that the /etc/hostname is not set automatically in case of change at the boot.conf file. This behavior will be changed on the next release of boot-66serv package.

Powered by Obarun