There are two ways to do this:
Easy: While exploring, scan the area or system with
and look for a habitable base, shown as a red hexagon. Enter the base and interact with the terminal to claim it.
Hard: Save a bunch of money and purchase a freighter.
Happy exploring!