Causes of kidney infection • A kidney infection happens when bacteria enters and infects one or both of your kidneys. The bacteria is usually a type called E. coli, which live in your bowel.
• The bacteria get in through the opening of the urethra and move upwards through your urinary tract, first infecting your bladder and then your kidneys.
• It's thought that one way the bacteria get in to your urinary tract is by accidentally spreading from your anus to your urethra. This can happen if you wipe your bottom after going to toilet and the soiled toilet paper comes into contact with your genitals. It can also happen during sex.
• In rare cases, a kidney infection can develop if bacteria or fungi infect the skin and the infection spreads through your bloodstream and into your kidney. However, this type of infection usually only occurs in people with weakened immune systems.
Ref:
http://www.nhs.uk/Conditions/Kidney-infection