So I'm trying to set up PostgreSQL to be used with metasploit on my Mac 10.9 Mavericks machine. I'm trying to follow the instructions outlined on this page. http://www.darkoperator.com/installing-metasploit-framewor/ and I got to the command:
createuser msf -P -h localhost
here is the result:
$ createuser msf -P -h localhost
Enter password for new role:
Enter it again:
createuser: could not connect to database postgres: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "myname", database "postgres", SSL off
I changed the part that says "myname" to that because I dont want to post my name on here. I've searched the internet for a couple days for a solution to this and I'm pretty sure I need to edit pg_hba.conf. Here is my pg_hba.conf file's contents:
80 # TYPE DATABASE USER CIDR-ADDRESS METHOD
81
82 # "local" is for Unix domain socket connections only
83 #local all all trust
84 host all all 0.0.0.0/0 md5
85 local all all md5
86 # IPv4 local connections:
87 host all all 127.0.0.1/32 md5
88 # IPv6 local connections:
89 host all all ::1/128 md5
90
91 # TYPE DATABASE USER ADDRESS METHOD
92 #local postgres postgres trust
93 #local msf_db msf_user trust
94 # Allow replication connections from localhost, by a user with the
95 # replication privilege.
96 #local replication postgres trust
97 #host replication postgres 127.0.0.1/32 trust
98 #host replication postgres ::1/128 trust
Can you tell me what I need to add/remove(comment out) from this section to get postgresql up and running?
Let me know if you need any more info to help me learn how to solve this. Thank you!!
EDIT 1:
I was told all I need to do is restart the database and this is what I get:
sh-3.2# pg_ctl stop -D /opt/local/var/db/postgresql93/defaultdb
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
I logged in as su to complete this...
EDIT 2:
I then tried to complete this using my default user and this is what I got (I am certain I typed the correct password for myself)
sxxx:~ sxxx$ createuser msf -P -h localhost
Enter password for new role:
Enter it again:
Password:
createuser: could not connect to database postgres: FATAL: password authentication failed for user "sxxx"
EDIT 3:
Thanks to the help of some others I found out I need to log in to my postgres user to create this. I'm still not able to complete this here is what I did:
Sxxx-MacBook-Pro:~ sxxx$ sudo su - postgres
Sxxx-MacBook-Pro:~ postgres$ createuser msf -P -h localhost
Enter password for new role:
Enter it again:
createuser: could not connect to database postgres: FATAL: role "postgres" does not exist
which seems weird to me.
EDIT 4:
Miraculously I closed my terminal window and opened a new one and the same thing I had been doing this whole time worked:
Sxxx-MacBook-Pro:~ sxxx$ createuser msf -P -h localhost
Enter password for new role:
Enter it again:
Sxxx-MacBook-Pro:~ sxxx$ createdb -O msf msf -h localhost
Sxxx-MacBook-Pro:~ sxxx$
Check what user PostgreSQL is running as. Usually this will be pgsql
or postgres
. Run the createuser
command as that user.
$ sudo su
# su postgres -c 'createuser msf -P -h localhost'
You probably don't need to touch the pg_hba.conf
file.