I presume you are talking about resolving the server name inside your LAN. For this to work, you must have at least one of these:
A working DNS inside your own LAN (or on a companion LAN, performing this job for your LAN too).
An entry in the client /etc/hosts file, associating name and IP address.
A working samba server on the ssh server, where you have set the server's NetBIOS name. This allows you to be seen through Microsoft specific protocols.
Lastly, you may use multicast, what Apple calls Bonjour.
Each of these possibilities is mirrored in your file /et/nsswitch.conf, in the line:
hosts: files dns mdns4 mdns4_minimal wins
which determines the order in which these different services are used; the order above is best for my LAN since I do have a local DNS server, but yours may differ.
The easiest solution is most likely the one involving samba: install the samba server,
sudo apt-get install samba
for Debian and derivatives, change accordingly if not on Debian and Co., then edit the file /etc/samba/smb.conf, and set the lines
workgroup = WORKGROUP
NetBIOS name = YourPCNetBIOSName
to reflect data appropriate to your pc, then restart the samba service,
sudo service samba restart
again for Debian and derivatives, and now your ssh-client will be able to find the ssh-server through the name YourPCNetBIOSName, as specified above, provided the ssh-client does have the wins option in its own /etc/nsswitch.conf file.
You may wish to enable mdns as well, to be able to interact with Apple's pcs as well. After much trying, I discovered that the library libnss-mdns is not installed by default on Debian and derivatives, so, in order to be able to use multicast Domain Name Service (mdns) you will have to install it first:
sudo apt-get install libnss-mdns
At this point, you will be able to resolve Apple pcs as well.
Did hostname lookups work before you changed the hostname? Since you tagged it with DNS, does the PI have a DNS entry for the host? – Ƭᴇcʜιᴇ007 – 2014-12-17T17:31:51.710
Well no it does not have a DNS Entry. Its part of a workstation group. edited tag. No the orginal hostname did not work. I guess I'm trying to understand how hostnametest (hostname) could be associated with ip: 192.168.0.XX , especially when the IP is dynamic. – Benjamin Jones – 2014-12-17T17:51:08.437
From the client, can you run a name server lookup?
nslookup newhostname
and press Enter. What comes up? – Canadian Luke – 2014-12-17T17:53:22.9733You need either a DNS record in your DNS server, a HOSTS entry on your system, or working NetBIOS to perform hostname lookups. If you have none of those, then you have nothing to resolve the name to the IP, and so of course it doesn't work (dynamic or not). ;) – Ƭᴇcʜιᴇ007 – 2014-12-17T17:54:22.790