Old English sceacan "move (something) quickly to and fro, brandish; move the body or a part of it rapidly back and forth;" also "go, glide, hasten, flee, depart" (related to sceacdom "flight"); of persons or parts of the body, "to tremble" especially from fever, cold, fear" (class VI strong verb; past tense scoc, past participle scacen), from Proto-Germanic *skakanan (source also of Old Norse, Swedish skaka, Danish skage "to shift, turn, veer"). No certain cognates outside Germanic, but some suggest a possible connection to Sanskrit khaj "to agitate, churn, stir about," Old Church Slavonic skoku "a leap, bound," Welsh ysgogi "move."
Of the earth in earthquakes, c. 1300. Meaning "seize and shake (someone or something else)" is from early 14c. In reference to mixing ingredients, etc., by shaking a container from late 14c. Meaning "to rid oneself of by abrupt twists" is from c. 1200, also in Middle English in reference to evading responsibility, etc. Meaning "weaken, impair" is from late 14c., on notion of "make unstable."
To shake hands dates from 1530s. Shake a (loose) leg "hurry up" first recorded 1904; shake a heel (sometimes foot) was an old way to say "to dance" (1660s); to shake (one's) elbow (1620s) meant "to gamble at dice." Phrase more _____ than you can shake a stick at is attested from 1818, American English. To shake (one's) head as a sign of disapproval is recorded from c. 1300.