When you give a host a hostname, only this host knows about it. Any other host doesn't know the hostname (and the IP address it corresponds to) at all. A little different are name services (like DNS, NIS, ...), which "distribute" this knowledge across a network. But for our purposes only the host himself knows its hostname.
Having said this: you want to connect from a system (let us call it "yourpc") to another system ("pi"). For this to work "yourpc" has to know which IP address corresponds to this name "pi". In absence of any name service there is one way to enlighten "yourpc", which is: enter the hostname and its corresponding IP address to the file /etc/hosts. In fact this is the specific purpose of this file.
A typical /etc/hosts file looks like this:
# Place comments after octothorpe signs, like in shell scripts
10.1.1.1 host1
10.1.1.2 host2
10.1.1.3 host3 # an inline comment is also possible
# you can also specify "aliases" - multiple names under which the host is also known
10.1.1.4 host4 myraspberrypi
...
As an afterthought and thanks to a suggestion of @Archemar:
User names are irrelevant on the IP level. At this level we deal only with hosts (or, rather, their interfaces), networks and similar entities. Users or their names never enter this picture at this level.
Using the above example hosts-file the following are all equal:
ssh [email protected]
ssh someuser@host4
ssh someuser@myraspberrypi
sshing from ? from pi to pi ? (that's should be OK) from mac to pi ? you should use pi's hostname or IP. can youssh [email protected]?pingshould be used with an IP address or a resolvable name. Inserting a username[email protected]would not be expected to work.ssh [email protected]does work, so doesssh 192.168.xxx.xxx.