37

I followed this article to factory reset my device https://support.apple.com/en-us/HT212749

The article itself basically says to factory reset using this method before selling your computer. I did it. Gave the computer to my friend, my friend created a new account. Opened up terminal and now he sees friend@Coltons-Air.

Should I be worried about any other info being left there?

2

2 Answers 2

41

This is unlikely to be a security issue, nor any issue with data retained on the machine. Terminal shows the DNS name provided by the network if your friend hasn’t overridden the default setup.

Instead, what is happening is that the router that your friend is using is remembering the old cached hostname of your computer Coltons-Air, and it is assigning it to the computer.

If you performed the “Erase All Content and Settings” from the Apple article, then your machine has been factory reset, with no data retained.

Check out this other post for more details for a similar person concerned about wrong identity in the terminal app. For reasons, Apple made the shell (bash or zsh typically) to use what the router stored for the last computer seen and not use the name of the Mac connecting. To fix this:

sudo scutil --set HostName 'not-Coltons-Air'
13
  • 15
    The source is not the computer, but the router.
    – Scot
    Jan 27 at 4:51
  • 28
    @Skye-AT Really it doesn't make sense that the Mac uses an externally provided name as default hostname... it does however explain why you see that as hostname though.
    – GACy20
    Jan 27 at 13:06
  • 12
    Wait, you mean that the value of $HOSTNAME on mac systems depends on what name a machine is assigned by the router on the network? What if the machine isn't connected? Is there no /etc/hostname or is it ignored? (um... please feel free to tell me to post a new question if this is going off on a tangent).
    – terdon
    Jan 27 at 14:25
  • 4
    @terdon: Huh… if that's really the case, I wonder if it's exploitable. Surely there must be some scripts that assume the hostname doesn't contain any funny characters (like, say, spaces or slashes or nulls), because who'd be so silly as to use a hostname like that, right? Jan 27 at 23:23
  • 6
    My friend was indeed on my network when he setup the laptop. We're going to try to wipe the laptop again tomorrow and connect to a brand new network and we'll see if it happens again. I'll keep you all updated. Jan 28 at 5:55
2

You need to change HostName, ComputerName and LocalHostName.

Changing HostName alone will not solve this issue.

Just to add onto Scot’s answer, yes Hostname is associated to the router value. But if you really want to clear out any reference to the old names you need to change three different, yet seemingly similar, settings: They are HostName, ComputerName and LocalHostName and you can run the commands as follows; just change yourHostName to whatever you want to set them to.

sudo scutil --set HostName 'yourHostName'
sudo scutil --set ComputerName 'yourHostName'
sudo scutil --set LocalHostName 'yourHostName'

The breakdown of each setting is this; details courtesy of this post on OSXdaily:

  • HostName: The name assigned to the computer as visible from the command line, and it’s also used by local and remote networks when connecting through SSH and “Remote Login.”
  • ComputerName: The so-called “user-friendly” computer name for a Mac, it’s what will show up on the Mac itself and what will be visible to others when connecting to it over a local network. This is also what’s visible under the “Sharing” preference panel.
  • LocalHostName: The name identifier used by Bonjour and visible through file sharing services like AirDrop.

So yes, the router caching plays a role, but macOS stores three different, yet related, “hostname” values in the system. You must change all three to be assured any remnants of past values are gone.

1
  • Would love to know why this answer was downvoted. To the best of my knowledge, all three values (HostName, ComputerName and LocalHostName) need to be changed to remove all signs of the previous values for the machine. Jan 30 at 23:14

You must log in to answer this question.

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