I have a Ruby script (https://github.com/jhsu802701/bsf-scrape/blob/master/scrape.rb) that scrapes web pages and stores the results in a Postgres database. I’m trying to set this up not only in the development environment but in a production environment as well, and the production environment is giving me authentication errors.
I’m confused over the names and passwords. There are:
1A. Local machine (user1A and password1A): used for logging in when I boot up Linux, owner of the Ruby script
1B. Local Postgres (user1B and password1B): the username and password for PostSQL
1C. Name of the local Postgres database (db1C)
2A. Web host SSH (user2A and password 2A): the username and password for connecting to the production environment through SSH
2B. Web host Postgres (user2B and password 2B): the username and password
2C. Name of the remote Postgres database (db1C)
The script has a class called FundDatabase.
A password needs to be specified in the conn function within the FundDatabase class:
@conn = PG.connect(
:dbname => $db_name,
:user => $db_user,
:password => $db_password)
I keep getting confused. My questions:
- When I create a local superuser (user1B) with the command “CREATE ROLE [local username] SUPERUSER LOGIN;”, why don’t I need to provide a password (password1B) specific to this user?
- In order to get my script to run, user1B must be the same as user1A, or I get an authentication error. Am I correct in using the same usernames both for my local machine and the local Postgres database?
- In the @conn function in my script in the production environment, am I supposed to use my SSH login (user2A) and password (password2A)? Or am I supposed to use my database login (user2B) and password (password2B)? Do user2A and user2B need to be one and the same (just like user1A and user1B)?