SSH to Macbook works when lid closed (and plugged in to power)
Yes, this is the Power Nap feature at work. On Mac notebooks, by default, Power Nap is configured as enabled when it's connected to AC power and configured as disabled when on battery (you can see this from System Preferences > Energy Saver). This is why you're seeing different behavior when connected to mains power and when on battery.

You don't have to worry about overheating since the Power Nap feature comes with built-in protection for it. Read the OS X: About Power Nap article for more information. It states (emphasis mine):


  Power Nap communicates and transfers data for a only a few minutes per Power Nap cycle when running on battery. When connected to a power adapter, communications and data transfers are continuous. When Power Nap is enabled your computer may be warm to the touch even if it is sleeping. Power Nap operations are suspended when your computer exceeds a predefined temperature so that your computer does not overheat.