How did soldiers from ancient history to beyond maintain weapons and armour? Could a knight get under to check the tang of his weapon for rust?
Well, it depends on who you are, what armor you're wearing, when you are and finally where you are.
Steel that is not stainless or galvanized rusts very quickly so maintaining armor is more or less a daily chore if you're in the field or at best "after every use" if you're not in the field. In so far as we know, the method of protecting armor against rust has not changed much over the years but the materials have. Let's look at protection first.
Paint and lacquer - On a very fundamental level paint and lacquer function like galvanization does today. You cover the steel in a layer of something that shields it from oxidization. The advantage is that is lasts a fairly long time, the disadvantage is that every chafe, scratch, dent and notch has to be repaired or it will be a point of entry for water and therefore rust. You can see beautiful examples of lacquered armor throughout Japanese history.
Oil and wax - Like paint and lacquer oil and wax applies a protective coating to the armor that keeps water out. It's not nearly as durable as paint or lacquer but on the upside, it's much easier to maintain. All you need is a stick of wax or a cloth and a bottle of oil and you're good to go!
Tinning and lining - This is mostly for the inside of the armor but still relevant I think. Because people get sweaty the inside of armor is particularly vulnerable to rust. A thin layer of tin will prevent rust from forming, lining the armor with cloth will prevent it from staining whatever you're wearing underneath. At least in theory. It will also make the armor drastically more comfortable. It might also be worth mentioning that some types of armor like the jack of plates and coat of plates are technically lined armor as the metal plates are sewn or riveted into a cloth or leather garment.
So, what if you get rust on it anyway? It's bound to happen right?
Yes, yes it is and there is a universal remedy for it. Vinegar (or something else that is sufficiently acidic), sand and elbow grease. You apply vinegar, then a little sand soaked in vinegar and then you scrub. Once done you wash it, dry it and reapply whatever coating the armor had.
Chain mail is a bit of a special case, you don't want to be polishing every god damned ring by hand, it'd take an age and half. Fortunately, you usually won't have to. As long as chainmail is kept oiled it does a surprisingly good job of maintaining itself. It basically scrubs itself against whatever you're wearing under it (usually padded armor of some sort) and/or over it (perhaps a surcoat), it even scrubs itself against itself. It does stain though. Good lord does it stain. Everything. If it still needs cleaning you can always stick it in a barrel of sand and roll it down a hill. It's basically a medieval washing machine for mail.
Seems like a lot of work, doesn't it? It is, but it sure is better than getting gutted so you want to do it anyway. So who did it? Well, that depends on who you are.
If you're a common soldier, you're doing it yourself. Congratulations, maintaining your armor is going to be a major part of your day but hey, at least you have armor! If you're a noble/officer you're more likely to have a manservant/squire/slave or basically someone else who does this for you. Life is good! If you're very rich you might even have your personal armorer or, if you're very very rich, armory, that not only dresses you in armor but also cares for, modifies and makes armor for you. It is good to be the king!
In general terms, there are relatively few sources on the maintenance of armor. There are records of payments to armorers for maintenance, descriptions that maintenance of armor is part of a certain persons duties and so on but relatively few sources that go into any detail on how it was actually done. I have found two relatively interesting studies done on the making and maintenance of medieval armor if you want further reading:
This one by Nickolas Dupras titled "The Tools and Techniques of Late Medieval Armour Production"
http://etheses.whiterose.ac.uk/4376/1/Dupras%20PhD%20Thesis%20Volumes%201%20%26%202.pdf
And this one by Roland Thomas Richardson titled "The medieval inventories of the Tower armouries 1320–1410"
http://etheses.whiterose.ac.uk/3919/1/Thom_Richardson_thesis_final.pdf