If you have a morphism $f:G\to N\,,$ then you get a $K$-extension of $G$ by pulling back the $K$-extension of $N\,.$ The morphism $f$ lifts to a morphism into $M$ if and only if this extension is trivial. So you could show the map you want is surjective by showing that all $K$-extensions of $G$ are trivial.
If $K$ is abelian, then isomorphism classes of $K$-extensions correspond to classes in (abelian) group cohomology.