In this tutorial, we will assume that the hostname you want is pluto.
On your SSH Terminal, type: hostname pluto
Using nanoYou can then type: nano /etc/hostname
Type in pluto, then press Ctrl + X, then Y, then Enter.
Now, again using nano, type nano /etc/hosts to edit the hosts file.
Add another line on top, it should read: 127.0.0.1 pluto
Confirm your changes by typing hostname.
Newer Ubuntu versions make it even easier; you can just type: hostnamectl set-hostname pluto
Confirm your changes by typing hostname.