How Do You Deploy LAPP with Frontend User Authentication?

Problem scenario
You want a web page that asks for a username and password (e.g., to log in).  The users will not know if the authentication is done via Apache or Postgres.  You happen want the authentication to be challenged against a Postgres database.  This way if you have backend access to the Postgres database, you can use "CREATE ROLE" or "CREATE ROLE jane PASSWORD 'veryfun' LOGIN" to create users.  You will be able to provide the users with the credentials and web URL.  They will gain access to another page other than the landing page if authentication is successful.  This second page may or may not invoke SQL commands.  The users will not need to have knowledge of SQL.  They will not need special software installed on their computers.

How do you deploy LAPP (Linux, Apache, Postgres, and PHP) with a web page frontend to challenge credentials?

Solution
Make sure you understand the security risks of this before implementing it.  This example solution assumes you have installed Apache web server, PHP, php-pgsql, and Postgres on a Linux server (i.e., you have deployed LAPP and need to install php-pgsql).  To install LAPP see this link.  To install php-pgsql, see this link.  This solution also assumes the default location for the web files is /var/www/html/.  Standard deployments of Apache (without special configuration) on Debian/Ubuntu distributions of Linux use this location.

#1  Put this file (<html> tag to </html> tag below) in /var/www/html/ under the name gooda.php:

<html>
<body>

<form action="goodb.php" method="post">
UserName: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="submit">
</form>

</body>
</html>

#2  Put this file  (<html> tag to "end of file")  in /var/www/html/ under the name goodb.php:

<html>
<body>

Username entered: <?php echo $_POST["username"]; ?><br>

<?php $part1 = $_POST["username"]; ?>
<?php $part2 = $_POST["password"]; ?>
<?php $comp = 'user='.$part1.' password='.$part2 ; ?>

</body>
</html>

<?php // echo "Hello world!";
   $host        = "host=127.0.0.1"; 
   $port        = "port=5432";
   $dbname      = "dbname=cooldb";
   $credentials = $comp;

   $db = pg_connect( "$host $port $dbname $credentials"  );
   pg_query("CREATE DATABASE niftydb");

?> //end of file

3.  Change the "cooldb" to the name of an existing database.  Change the "niftydb" to the name of the database you want the SQL DDL command to create.  You may want to change the pg_query command altogether.  It is up to you as this is just an example.

4.  Know that this is a proof-of-concept for educational purposes. For sensitive passwords over the internet, you may want other authentication and security in place.  These PHP files would be appropriate behind a firewall in an enterprise's development or QA environment.  If you browse to the gooda.php page from a web browser (assuming the postgres and Apache web services are running on the Linux server itself), you will be able to type in a username and password for Postgres.  The pg_query command will run if the authentication was successful. 

A List of Git Books

19 Git Tips for Everyday Use by Alex Kras
The Beginner's Guide to GitHub by Thomas Mailund
Building Tools with GitHub: Customize Your Workflow by Chris Dawson and Ben Straub
Distributed Version Control with Git: Mastering the Git Command Line - Third Edition (vogella Series) by Lars Vogel and Alex Blewitt
Dive into GIT by James Ware
Eclipse 4.5 Git Course for Java Eclipse Developers by John R. Hines
Get GIT in a Flash: Just What You Need to Know to Start by Cheryl Mason
Git: Best Practices Guide by Eric Pidoux
Git Distilled by Peter Bell
Git: Distributed Version Control—Fundamentals and Workflows by René Preißel and Bjørn Stachmann
Git Essentials by Ferdinando Santacroce
GIT for IT Students by Dorothy Andrews
Git for Teams: A User-Centered Approach to Creating Efficient Workflows in Git by Emma Jane Hogbin Westby
GIT for Techies by Rhea Kitchen
GIT for Universities by Robert Charles
Git in Practice: Includes 66 Techniques by Mike McQuaid
Git Magic by Ben Lynn
Git Memento by Jie Deng
Git Overview: With Command-Line Incantantations by J Adrian Zimmer
Git Pocket Guide: A Working Introduction by Richard E. Silverman
Git Recipes: A Problem-Solution Approach by Wlodzimierz Gajda
Git Version Control Cookbook - 90 Recipes to Transform your Development Workflow and Boost Productivity by Aske Olsson and Rasmus Voss
Git: Version Control for Everyone by Ravishankar Somasundaram
Git Version Control Guide: Step -by-step tutorial for beginners by Gregory Blake
Introduction to Git-flow: A Git Workflow and Development Model by Chris Weed
Jump Start Git: Take Control of Your Code and Assets by Shaumik Daityari
Learn Enough Git to Be Dangerous: An introduction to version control with Git (Learn Enough Developer Fundamentals Book 3) by Michael Hartl
Learning the Git Bash Shell: Become a Windows Command Line Commando by Michael Hanna
Learn Git in a Month of Lunches by Rick Umali
Learn Version Control with Git: A step-by-step course for the complete beginner by Tobias Günther
Mastering Git by Jakub Narebski
Pragmatic Guide to Git (Pragmatic Guides) by Travis Swicegood
Professional Git by Brent Laster
Pro Git by Scott Chacon
Pro Git by Scott Chacon and Ben Straub
Version Control with Git: Powerful tools and techniques for collaborative software development by Jon Loeliger and Matthew McCullough
What is Git ?! by Seyed Hossein Ahmadpanah

How Do You Create a Table in a Specific Database Using a SQL Front-End GUI Application?

Problem scenario
You are using a SQL front end to query a Postgres database.  (To view directions for installing a free front-end GUI application, click here.) You have run various commands to prove the connection to the database server works.  

Running this query

select version();

shows

"PostgreSQL 9.5.6 on x86_64-pc-linux-gnu, compiled by ..."

You have used CREATE DATABASE successfully.  When you try "create schema epsilon" you get "Error: permission denied for database postgres."  You have a database called "theta."

You have tried using the "connect" word in your SQL queries.  You have tried expanding "public" to find the "theta" database using the GUI portion of my SQL front end.  But you cannot seem to create database-specific tables or schemas.

How do you create a table in a specific database from a SQL front end (GUI application)?

Solution
This assumes the SQL front end GUI application has connected to the Postgres database.  On the left-hand side, right click the database's name (under "public").    Go to CREATE NEW -> TABLE.  In the "Name" field type the desired name of the new table.  Use the "Add" button to add tables.  You can set the Datatype as desired.  The column names can be modified according to your desires.

A List of Apache Tomcat Books

Apache Jakarta-Tomcat by James Goodwill
Apache Tomcat 7 by Aleksa Vukotic and James Goodwill
Apache Tomcat 7 Essentials by Tanuj Khare
Apache Tomcat 7 User Guide by Apache Software Foundation
Apache TomEE Cookbook: Apache TomEE Administrator Cookbook by Mr Gurkan Erdogdu 
Beginning JSP, JSF and Tomcat: Java Web Development (Expert's Voice in Java) by Giulio Zambon
Connection Pooling in a Java Web Application with Tomcat and NetBeans by Arthur Buliva
Deploying with JRuby 9k: Deliver Scalable Web Apps Using the JVM by Joe Kutner
Developing a Java Web Application in a Day: Step by step explanations with Eclipse Mars, Tomcat and MySQL (Java Web Programming Book 1) by Luciano Manelli
Doing More with Java: Android and Tomcat Edition by Lee Barney
From Tomcat to WildFly in one day by Francesco Marchioni
How Tomcat Works by Budi Kurniawan  and Paul Deck
Java Extreme Programming Cookbook by Eric M. Burke and Brian M. Coyner
Java Programming Interviews Exposed by Noel Markham
JRuby Cookbook by Justin Edelson and Henry Liu
Mastering Tomcat Development (Java Open Source Library) by Ian McFarland and Peter Harrison
Mastering Ubuntu 16.04 LTS Server Installation and Administration: Training Manual: Covering Application Servers: Apache Tomcat 9, JBoss-eap 6, GlassFish 4, Eclipse IDE, and Backtrack 5 Pentest by Kefa Rabah
MySQL and JSP Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner
Pro Apache Tomcat 5/5.5 (Expert's Voice in Java) by Matthew Moodie
Pro Apache Tomcat 6 by Matthew Moodie and Kunal Mittal
Professional Apache Tomcat by Chanoch Wiggers, Ben Galbraith, Vivek Chopra, Sing Li, Debashish Bhattacharjee, Amit Bakore, Romin Irani, Sandip Bhattacharya and Chad Fowler
Professional Apache Tomcat 5 (Programmer to Programmer) by Vivek Chopra, Amit Bakore, Ben Galbraith, Sing Li and Chanoch Wiggers
Professional Apache Tomcat 6 by Vivek Chopra, Sing Li and Jeff Genender
Professional Java for Web Applications by Nicholas S. Williams
Pro SpringSource dm Server by Gary Mak and Daniel Rubio
Sams Teach Yourself JavaServer Pages 2.0 with Apache Tomcat in 24 Hours, Complete Starter Kit by Mark Wutka, Alan Moffet and Kunal Mittal
Tomcat 5 Unleashed by Lajos Moczar
Tomcat 6 Developer's Guide by Damodar Chetty
Tomcat: The Definitive Guide by Jason Brittain and Ian F. Darwin
Tomcat Kick Start by Martin Bond and Debbie Law
Web Facing Now! Tomcat Edition by Craig Pelkie

How Do You Troubleshoot the Postgres Message “ERROR: permission denied to create database”?

Problem scenario
From a SQL front end you are connected to a Postgres database as user jdoe.  You try to create a database with the "create database verycool" SQL command.  You get this message: "ERROR: permission denied to create database."

You try to enter the database from the back end, but you get 'psql: FATAL: role "root" does not exist.'   Or you may even get the error "psql: FATAL:  Peer authentication failed for user" when trying to connect or log into Postgres.  What do you do with these errors?

Solution
From the Linux back end, run these four commands:

# sudo -u postgres -i

# psql

# alter role jdoe createdb;

# \q

Now the jdoe user should be able to create a database.

How Do You Troubleshoot HAProxy when The Service Seems to Work on The Back-end but You Cannot Use It from The Front-end (via a web browser)?

Problem scenario
Your HAProxy server seems to be up, but it is not working (as a load balancer or otherwise).  You use nmap or a PowerShell port testing program (see "Using PowerShell Version 3, How Do You Determine If a Port Is Open for a given IP Address?").  You find that there is activity on port 80 and/or the traffic is not blocked over port 80.  But when you open a web browser, you get "File not found" or "The site cannot be reached."  What do you need to do?

Possible Solution #1
Start the HAProxy service (if it was not already started).  Use this command: sudo /etc/init.d/haproxy restart

Possible Solution #2
Is traffic blocked from your HAProxy server?  Verify you have connectivity from your HAProxy server to your webserver(s).  The port is determined in the haproxy.cfg file (e.g., 5001 or 80). 

How Do You Install Telnet on a Windows 7 Machine?

Problem scenario
You want to use Telnet on your Windows 7 computer.  When you try to use telnet, you get
"'telnet' is not recognized as an internal or external command, operable program or batch file."

How do you fix this?

Solution
1.  Open a command prompt hold the Windows key, tap the r key once, then release. Then type in cmd and press Enter.

2.  In the command prompt, enter this:

pkgmgr /iu:"TelnetClient"

Press Enter and wait two minutes.  There will be no evidence that anything is progressing.  Without having to close the command prompt, telnet will be eventually be available when the process silently completes.

A List of Books About Website Performance, High Availability and Scalability

The Art of Scalability: Scalable Web Architecture, Processes, and Organizations for the Modern Enterprise (2nd Edition) by Martin L. Abbott and Michael T. Fisher 
Cloud Computing for Complete Beginners: Building and Scaling High-Performance Web Servers on the Amazon Cloud by Ikram Hawramani
Even Faster Web Sites: Performance Best Practices for Web Developers by Steve Souders
Getting Started with Memcached by Ahmed Soliman
High Performance Drupal: Fast and Scalable Designs by Jeff Sheltren, Narayan Newton and Nathaniel Catchpole
Instant Varnish Cache How-to by Roberto Moutinho
MySQL High Availability: Tools for Building Robust Data Centers
 by Charles Bell, Mats Kindahl  and Lars Thalmann

Can SSH Work between a Linux Server and a Windows Client When the Window’s Machine Has Inbound Port 22 Traffic Blocked?

Question
Can SSH work between a Linux server and a Windows client when the Window's machine has inbound port 22 traffic blocked?

Answer
Yes.  Some VPN tunnels initiated on a Windows machine block inbound port 22 traffic (but not all).  Regardless of whether a firewall or VPN tunnel prevents inbound connections over port 22 to a Windows machine, you can make establish an  SSH connection over port 22 from a Windows machine.  

The destination server of an SSH request must listen on port 22.  The source port of SSH requests will not be 22.  To initiate an SSH connection, the egress direction of port 22 must not be blocked by intermediate security configurations.  The ingress ports to the Windows machine over port 22 can be blocked, and you will still be functionally permitted to connect via SSH from the Windows machine (e.g., with Putty).

A List of Informatica Books

Agile Data Warehouse Design: Collaborative Dimensional Modeling, from Whiteboard to Star Schema by Lawrence Corr and Jim Stagnitto
Applying SOA Principles in Informatica: Applying Service Oriented Architecture (SOA) principles in Informatica PowerCenter by Mr Keshav Vadrevu
INFORMATICA INTERVIEW QUESTIONS & ANSWERS: Hands on tips & questions to crack the interview. by ks
Informatica Powercenter 9.x ETL Developer Including 20+ Hours of Online Video Tutorial by Rudrani Josh
Informatica PowerCenter - The Complete Reference: The one-stop guide for all Informatica Developers by Mr Keshav Vadrevu
Learn Informatica in 1 Day: Definitive Guide to Learn Informatica for Beginners by Krishna Rungta
Learning Informatica PowerCenter 9.x by Rahul Malewar
SAP and Informatica PowerCenter Internal Tables: Consultant Guide by Mirzakhmet Syzdykov

For a DevOps ETL quiz, click here.