A classic with join:
join -t: -1 12 -2 21 -o 2.1,1.1,1.2 <(sort -t: -k1,1 file1) <(sort -t: -k2,2 file2) -t:specifies the colon as separator.-1 12file1's join field is the firstsecond one-2 21file2's join field is the secondfirst one-o 2.1,1.1,1.2the output format.<(...): both files must be sorted on the join field (-k1,1and-k2,2),-t:specifies the colon as separator forsort.