"ORA-24454: client host name is not set" when connecting from Ubuntu instance on AWS EC2
After two hours, I figured it out.

Oracle's documentation for the error didn't seem terribly descriptive at first:


  ORA-24454: client host name is not set
  
  Cause: The network host name in files like /etc/hosts was not set.
  
  Action: Set the host name and try again.


Now, the command worked on my machine (Ubuntu laptop), but it didn't work on EC2. I mucked around with the HOSTNAME variable for a bit and tried to figure out if there was a way to override the "client host name" in sqlplus's settings -- no dice. I finally compared my machine's /etc/hosts to the one in EC2, and noticed this line that wasn't in EC2:

127.0.1.1 my-laptop-hostname


I didn't know this before, but apparently it's normal on Debian-based machines to map the system's hostname to this IP address. I didn't even know that 127.0.1.1 was a loopback IP; I just knew about 127.0.0.1.

What's more, it seems sqlplus relies on this line being present. Still no idea why.

Anyway, the fix is simple:

$ sudo /bin/bash -c "echo '127.0.1.1 ${HOSTNAME}' &gt;&gt; /etc/hosts"