38

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?

Giacomo1968
  • 5,623
c_idle
  • 521

2 Answers2

42

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'
Giacomo1968
  • 5,623
Scot
  • 8,045
  • But why would factory reset Macbook would still got a cache for the hostname? Shouldn't it be deleting every single data that isn't available at factory-new Macbook? – Skye-AT Jan 27 '22 at 04:51
  • 15
    The source is not the computer, but the router. – Scot Jan 27 '22 at 04:51
  • Ooh, that makes sense. And sorry, I missed your edit that you've added a link to relative post. Thanks for sharing. – Skye-AT Jan 27 '22 at 05:10
  • 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 '22 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 '22 at 14:25
  • 1
    @GACy20 I mean, it makes sense in a way of latter. Not saying that it should work like that; especially if it's after factory reset (Plus, in this case, I assume his friend's on another network, so it actually doesn't make sense.) Sorry if my comment made confuse you. – Skye-AT Jan 27 '22 at 14:38
  • You can certainly override the network-assigned name of the device, if you want to. – Marc Wilson Jan 27 '22 at 15:53
  • 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? – Ilmari Karonen Jan 27 '22 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. – c_idle Jan 28 '22 at 05:55
  • 2
    @Scot right on the money with the answer (not that I doubted you, but I had to try it to believe it!) We reset the computer again, and hooked it up to a hotspot. At that point the laptops name in terminal was "foo@foos-Macbook-air". Connected to my wifi and bam. foo@Coltons-air. If we went back to the hotspot, then it changed back again. This is super interesting. I'm going to look up to see if I can wipe this name from my router somehow. I assume I can see past clients and maybe disassociate one of them? – c_idle Jan 29 '22 at 04:56
  • 1
    @coltonidle It's worth noting that you or your friend can set a permanent hostname for the Mac in System Preferences > Sharing > Computer Name (the textbox itself, and the Edit... button underneath). That way, it won't change randomly depending on which network you're on. – Dev Jan 29 '22 at 07:38
  • 2
    @coltonidle Nice! I’m glad you tested it out to see what’s happening. It’s a really strange artefact of MacOS, and since you wiped the computer, it really shows what is happening. – Scot Jan 29 '22 at 08:24
  • Instead of wiping the Mac again and traveling, reboot your router lol. – Harper - Reinstate Monica Jan 30 '22 at 00:01
3

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.

Giacomo1968
  • 5,623