Can I create host-specific users in Postgres? (ex: postgres@localhost)

Solution 1:

You haven't provide any info about your PostgreSQL version, I assume you're using PostgreSQL 12.

Can I set permissions on a user (ex: postgres) such that that user is only allowed to login from TCP localhost, but not the Internet?

Yes, use pg_hba.conf. You may want to load this first via hba_file runtime configuration.

For local and intranet access, however, I'd prefer to be able to have a username and password that I can remember (and type).

If you want to add a local-only user protected with a password, add

local <database_name> <local-only_user_name> scram-sha-256 

in your pg_hba.conf.

You probably want to create the user first via CREATE ROLE:

CREATE ROLE username LOGIN ENCRYPTED PASSWORD 'insert-your-password-here';

You may also want to check host and hostssl record entry to add to your pg_hba.conf to configure your intranet and internet based authentication.

Check linked documentations for more info.