To define complex shortcuts in LyX, the command-sequence functionality is very useful.
To construct exactly a sum with the limits as described, and position the cursor after the sum sign, but still in the math box, you can use
command-sequence math-insert \sum \limits _{}; down; math-insert \substack{}; newline-insert newline; math-insert 0<k<p; down; math-insert \gcd \left( k,p \right); char-forward; char-forward
Here, the ; marks a new command. The newline-insert newline does the trick of Enter. The cursor is moved by down and char-forward. Not used here, but available, are also up and char-backwards
(This is a cumbersome way of doing so, and could be replaced by command-sequence math-insert \sum\limits_{\substack{0<k<p\\\gcd\left( k,p\right) =1}}; char-forward; char-forward -- it is merely meant to illustrate the constructions used).
To produce just the sum with the two-rowed substack and the cursor in the top row, use
command-sequence math-insert \sum \limits _{}; down; math-insert \substack{}; newline-insert newline
From there, you should be able to move with the arrow keys and just type what you want (combined with shortcuts for \gcd etc. as suggested in Torsbjørns answer).