Hit it off, idioms and metaphors are congenial and can be combined at once.
The idiom comes from Chapter 18 of Qi Lu Deng, written by Lvyuan Li, a scholar in the Qing Dynasty: "The ancients said:' A friend of a gentleman should decide before seeking; The villain's friend immediately hit it off. " "