The Word Detective has the goods in a post titled: And gimme a hundred of them nickel seegars. Scroll down a bit to find it.
Short answer:
My best guess is that “to josh” as a verb meaning “to joke” came from “josh” as a noun meaning a “rube” or “hick,” which in turn was based on the fact that “Joshua” was considered a typical rural name back in the 18th century, and thus a handy (though unfair) label for anyone likely to be taken in by a simple trick.