Skip to content

Instantly share code, notes, and snippets.

@trev
Last active August 29, 2015 14:13
Show Gist options
  • Save trev/733e28b79ed6239e5006 to your computer and use it in GitHub Desktop.
Save trev/733e28b79ed6239e5006 to your computer and use it in GitHub Desktop.
Brain

Linux (Ubuntu)

Commands/Actions

$ visudo
# This allows user to sudo but prompts for password
dog     ALL=(ALL:ALL) ALL
# This allows user to sudo without prompting for password (not very secure but useful during automation)
dog     ALL=(ALL:ALL) NOPASSWD:ALL

Security

VSFTPD (FTP Server for Ubuntu)

PostgreSQL

Best Practices

  • Use Ident Authentication whenever possible. Basically this means access to the database uses the currently logged in user on the OS. For example: if your Rails application runs as the user dog connections to the PG database will use that user.

Commands/Actions

  • Become a PostgreSQL super user (postgres) to perform database operations unimpeded:
    • From root: $ su - postgres
    • From sudo: $ sudo su - postgres
  • Permit user to create databases:
$ psql
> ALTER USER username CREATEDB;
  • Create a database and permit the current user: $ createdb database_name

Rails

Example database.yml with PostgreSQL & Ident Authentication

# config/database.yml

default: &default
  adapter: postgresql
  pool: 5
  
development:
  <<: *default
  database: example_development

test:
  <<: *default
  database: example_test
  
staging:
  <<: *default
  database: example_staging
  
production:
  <<: *default
  database: example_production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment