3

I've been setting up an array of Mac Minis running Sierra, and I'm trying to be consistent about naming them.

However, for some reason, some of their ssh name@hostnames are different.

For example, the Computer Name and account names are all consistent, eg: Mini Kiosk 02 "mini-kiosk-02".

But their ssh info is sometimes different.

Some are "ssh mini-kiosk-02@mini-kiosk-02" while others are "ssh mini-kiosk-04@mac-mini".

I'm not seeing how I can change, eg, the part after the @ sign.

I thought scutil --set HostName etc might do the trick, but that doesn't seem to change anything.

Update

As you can see from the screenshot, hostname does not seem to correspond to what is after the @ in the Remote Connection settings.

Screenshot showing terminal window after hostname command showing "mac-mini" as hostname, with Sharing dialog open showing ssh mini-kiosk-02@mini-kiosk-02" in the Remote Login settings

2

Your command should work:

sudo scutil --set HostName YourHostName

Since OSX 10.9 Maverick, it's possible to change it with hostname command. Without -s it will be a temporary change, adding the -s will set it up permanently:

sudo hostname -s YourHostName

To verify it, you may type hostname and observe the return.

Update

OSX uses different variables to name the machine. You may need to reset them as well.

scutil --set HostName YourHostName
scutil --set ComputerName $(hostname -s)
scutil --set LocalHostName $(hostname -s)
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $(hostname -s)
  • Unfortunately, no. See attached screenshot in my updated answer. – Tom Auger Jan 17 '17 at 13:58
  • Here are the different steps I use when setting up a new mac. Does this solve your issue? – Kevin Lemaire Jan 17 '17 at 14:13
2

Did you see that you can also set the hostname via the hostname command?

So on a server try

sudo hostname kiosk-99

and then

hostname 

However, if your final intention is to access the computer from another machine as

ssh user@kiosk-99 

this will be (as the other poster suggested) a DNS issue, because the other computer (where you type the ssh command) will need to translate kiosk-99 into that machine's IP address, i.e. it's the same as trying to

ping kiosk-99 

and getting the right IP back from the name server.

Reasons then could be that you have multiple DHCP servers in the network, so when a kiosk asks the network for an IP address it gets some from different computers.

Have you checked if the IP addresses of the different miniMacs are similar?

  • Why would I have multiple DHCP servers? I only have one router, and I checked it and it's not doing anything special. It's showing the same hostnames as the ones I'm trying to change... – Tom Auger Jan 20 '17 at 19:55
1

This looks like a DNS issue.

Be careful to check the DNS settings on one machine at a time. Focus on the machine with the terminal doing the initial ssh. Let's call that testmac

Compare the ssh user@host with ssh user@IP.address to see how the DNS server is giving you information on the testmac.

Once you're sure the DNS on one machine is working, then you can know if you need to change your DHCP server to update DNS when the Mac in question (the target of ssh - not testmac) received a DHCP lease. Or you could hard code things in DNS and make DHCP reservations to match what you have set up in DNS.

Trying to scutil or hostname your way out of DNS issues usually is ineffective at best. The Mac .local names are for mDNS so you could ssh to host.local to avoid needing to mess with DNS. Depending on how many Macs are being run or if you have viable control over DHCP/DNS that might be a fair option for some situations.

  • Thanks for this angle. Just so I understand (DNS is far removed from my area of expertise) are we talking about our router that is assigning a DNS name to a machine based on its MAC address? Should I be logging into the router then? When you ask me to compare the user@host with user@IP what exactly am I comparing and how would I go about doing that? Through terminal or by looking at my router settings? – Tom Auger Jan 17 '17 at 14:35
  • 1
    Yes. The router does DHCP and DNS for most home and small networks. To get the IP address, look in networking preferences or use host mac-mini for example, @TomAuger – bmike Jan 17 '17 at 16:50
  • There's nothing going on at the router. It's showing the same hostname, with no aliases. It must be something else. I'm starting to think Bonjour? – Tom Auger Jan 20 '17 at 19:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .