Change ssh connection info for Remote Login
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.
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)
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?
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 [email protected]
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.