You can use a screw joint to move and rotate two bodies along and about a common axis.
An example of a screw joint is a nut on a bolt.