Creation of user is well-documented in many sources:
echo "
u = User.create(
:username => 'name',
:password => '12345678',
:password_confirmation => '12345678',
:email =>'email',
:reset_password => false,
:skip_confirmation => true,
:can_create_group => false,
:project_limit => 0,
:external => true,
:name => 'name')
u.save!
" | gitlab-rails console production
But how to assign SSH key to this user?