Here is way too much info on cranks and cotter pins, sone new, some from older posts.
The cranks are held on by "cotter pins". They are smooth and round with a tapered flat on one side which wedges them in place when you tighten the nut.
The best way to remove them, if they are in good shape, is to loosen the nut until it is flush with the end of the threads, then whack it with a brass hammer. When it comes loose, take off the nut and tap it out.
"Some rules. Cotter pins are installed with the threads in opposite directions. Cotter pins must have perfectly smooth flats, if you can't clean them up with a file, get new ones. Most bicycle shops should have them. With the left side pedal pointed forward, the right side cotter pin should have the thread pointed down, the left side, thread up."
This is a little more specific because it puts the heavyest loads on the widest part of the cotter pin. I also like to re-tighten the cotter pins after they have had a few minutes to seat or after the first ride.
Do not hammer the cotter pin in! Once the flat on the pin is notched from hammering, there is no way to tighten it. Make sure the tapered flat is not notched from previous use, that the crank and/or spindle are not worn to a bad fit by running with a loose cotter pin. Tighten the pin with a wrench while wiggling the crank to align it. Re-tighten after riding a little.