Is it possible to install macOS onto external SSD on a Mac running Ubuntu? Currently I am running only Ubuntu on my MacBook Air. Many have suggested I reinstall or install macOS on an external drive in case I ever need to troubleshoot, or in case something goes wrong. How can I install macOS on an external SSD from Ubuntu itself? Is this possible or do I need to use a friend's Mac?

In case Ubuntu didn't start up or break for whatever reason, would it be as simple as plugging in the SSD with the macOS and then pressing Option (Or optionally Alt) to boot from the SSD?
It is quite simple to install macOS on an external drive using macOS Internet Recovery.


Plug in the external drive.
Turn on or restart your Mac, then immediately hold down ⌘ + R keys.
Release the keys when you see the Apple logo or a spinning globe.
macOS Utilities window similar to the one below will be displayed.





Proceed to erasing the external disk by selecting Disk Utility and clicking continue.
Select your device or volume in the sidebar of Disk Utility.
Click the Erase button or tab.
Complete these fields:


Name: Enter a name for your disk, such as "Macintosh HD".
Format: Choose Mac OS Extended (Journaled) or APFS.
Scheme (if available): Choose GUID Partition Map.






Click Erase to begin erasing your disk.
When done, quit Disk Utility to return to the utilities window. You're now ready to install macOS.
Choose Reinstall macOS (or Reinstall OS X) from the utilities window.
Click Continue, then follow the onscreen instructions. You'll be asked to select your disk. Select the external disk (identify it with the value supplied for Name in step # 8).
Click Install. Your MacBook Air will restart after the installation is complete.




Voila! Your bootable external disk is now ready.

Yes, if you are unable to boot into Ubuntu for whatever reason, you can simply plug in the external SSD with the macOS installed and then press and hold Option (Alt) to boot from the external SSD?

To boot from the external disk:


Turn on or restart your MacBook Air with the external disk connected.
Press and hold the Option key immediately.
Release the Option key when you see the Startup Manager window.
Select your startup disk, then click the arrow under its icon, or press Return.