how do you connect a stepper motor?

Use a multimeter to measure the resistance between the wires. Assuming it's a 4-wire motor, you will find that there is a pair of wires connecting to each winding. If there's infinite resistance between a pair of wires, clearly those two wires are not on the same winding.

If it's a 6-wire motor, there are 3 wires per winding, with one being in the centre. You can tell which is in the centre by comparing the resistances between wires.