A shipmate is literally a mate on one's own ship (i.e., a member of the same ship).
In English-Speaking navies and the United States Coast Guard, the term 'shipmate' is used among sailors as a generic moniker. It is used in the third person by a member of a ship's crew to describe another member, or in the second person when referring to any other Naval service member.
In the United States Navy "shipmate" is most accurately a term used by anyone in the Navy to reference anyone else in the Navy. It can be used with a range of connotations- most often as an expression of camaraderie, but also as a respectful way to address other crew members whose rank or naval rating is not obvious. It can even be used in a derogatory manner. It is used both on land and at sea and it is used among Naval service members without regard to whether they are in fact members of the same ship. The term is used so abundantly in the American Navy that the inflection, context, and tone of the speaker can connote more meaning than the term itself.
In the United States Navy, recruits are indoctrinated with heavy use of the term immediately upon beginning training at Recruit Training Command (or 'boot camp'). There, they use the term abundantly to refer to their peers in all but the least formal settings. Notably, recruits use the term superfluously and with enthusiasm to sound off to their peers in scenarios when referencing another person by name or title would be otherwise unnecessary. For example, a recruit in the chow line will add "shipmate" after identifying each item of food he or she wishes fellow recruits to place on his or her tray ("potatoes, Shipmate!", "green beans, Shipmate!", "bread, Shipmate!" etc.). In turn, the recruits serving his or her food will repeat the expression as the recruit moves down the line "potatoes, Shipmate!", "green beans, Shipmate!", "bread, Shipmate!"... to confirm that they understood the commands. It is used so abundantly during this stage of a sailor's training that it can sound curious to a new recruit or a visitor. The term is almost never used by superiors to refer to inferiors during recruit training except ironically or in a derogatory tone. Sometimes the term is modified to connote the derogation more explicitly, as in "Shipwreck" in reference to someone who is messy or fails to maintain a military bearing. As the extreme hierarchical distinctions in recruit training tend to fade once the recruit joins the regular Navy, so do the above distinctions. It is not uncommon to hear an Admiral or Captain refer to his lowest subordinates as "shipmate" in order to express camaraderie. Inversely, it is not uncommon for peers to refer to one another as "shipwreck" or use a vocal inflection that connotes derogation, usually with an accent on the "-mate."