Backend · File System Related · How To · Linux · Web Security

How to use multiple ssh keys for different accounts

I wanted to have multiple rsa keys for various different hosts to help prevent hidden connection issues.

Issues may arises when an rsa key is changed on one host that may have been used on another host effectively severing the connection without your knowledge.

By having different rsa keys when dealing with a host that is critical, one may prevent this.

The ~/.ssh/config file (on your local machine) can be edited so that it will refer to different ssh keys for different hosts.

Open the ~/.ssh/config file in a plain text editor. Then make modifications like this:

Note that these are NOT the public key but the private key.

Save the file and now you computer will use the appropriate key when visiting a host.

Ansible · Apache · Backend · File System Related · How To · Linux · Web Security

How To Create a Password Hash with Python passlib

Create a password hash with python passlib

A quick and easy way to create a password hash is with python passlib.

Install passlib with pip like this:

Then, run the command below. Of course, you will replace the text “myplaintextpassword” with YOUR OWN plain text password, right?

You’ll get back something that looks like this.

Backend · File System Related · How To · Linux

Add Find to Mac OSx Command Line Terminal

Would you like to use the find command from the Mac OS command line terminal?

If you are using brew then you may do this very simply.

Its always a good idea to run the brew doctor before any installation.

Follow any steps the ‘doctor’ tells you to keep your brew in good health.

Be sure to run the brew update command.

With everything in order you can now install the brew find utilities like this.

The brew installation expects you to use the ‘gfind’ command. If you are used to typing ‘find’, you can simply alias the command like this.

Now you have the find command available to you at the command line terminal on your Mac OSX.

Backend · Drupal · File System Related · How To · PHP

Simple REST Client in PHP

A while back I created a Drupal module to act as a customized and extensible REST client. Since then I have used the module as a basis for other customized REST client code. I thought it might be a good idea to keep a copy of the dumbed down very basic code (not the Drupal module) in this post as a reference for myself and others to build off of in the future.

Any improvements or suggestions are welcome. However, please keep in mind that this is intended to be a scaffold on which to build customizations.

Backend · Drupal · Drupal 6 & Drupal 7 · File System Related · How To · PHP

How to Understand PHP Stream Wrapper Context and Options

Some have a difficult time understanding what is meant in PHP by stream wrappers, context options and parameters. Judging by a few conversations with other developers, its obvious there is a bit of confusion about what a stream wrapper is and why it would have a context. While the PHP documentation does adequately describe what this is, some just don’t “get it” the way that is described.

So if the descriptions of PHP Streams and Wrappers and contexts just make no sense when you read them, the following illustration is meant for you.

OK, picture yourself as a person in an assembly line. Whatever is coming down the line you need to be able to “handle it” and pass it along. Thing is, there are several possibilities of what might be coming down the line. It might be a hot casserole in metal pan. It might be a block of ice. It might be candy that needs to be wrapped. It might be glowing hot metal from a furnace. It might be liquid being poured from bucket to bucket. Can you see it in your minds eye?

OK, so if its liquid being poured from bucket to bucket, then you need a bucket, right? If it is a glowing hot piece of metal you better have your tongs handy! If it is a casserole fresh out of the oven then you need to have your stove mits on. If you being handed of a block of ice, then your large ice tongs will allow you to grasp it and pass it along.

The point is, to properly handle whatever is coming down the line (streamed data), you will need the appropriate tool(s) to handle the different kinds of items being passed (data types). The tools for handling each different kind of data type are the “parameters”. The parameters are like the tongs for the hot metal, the oven mits for the casserole or the foil in hand.

But how do you know which way of handling what is coming down the pipe? Simple, that is based on what the situation is. You know which type of item it is (which data type).

con·text (see link definition #2) synonyms: circumstances, conditions, factors

The “context” is determined by what exactly is being streamed. So for a different “contexts” (kinds of items) being “streamed” (passed along) the “parameters” (required tools for handling) the “data type” (kind of item) will change.

So for different data types being streamed the parameters will change. The term context simply makes reference to the fact that for different data types the situation is unique with its own required parameters. So now it hopefully makes sense to you that the PHP stream wrapper would require a context in order to know which parameters are needed to handle the data type.

The term “stream” makes reference to something being passed in or out of the application (on the assembly line).

The stream wrapper is code and relates to the person on the assembly line who is responsible for passing the stream along. It “decides” how to handle what is being passed.

The context is determined by WHAT is being passed along.
Based on the context, the option and parameters will change to properly handle what data type is being handled.

With that in mind, the concept is really quite simple. HTTP has options and parameters that are different from cURL options and parameters. PHP stream wrapper FTP options that differ from say SSL context options and so on.

Hopefully, with this understanding to help grasp what’s happening with PHP stream wrappers and contexts, reading the PHP stream wrapper documentation will make a lot more sense.

File System Related · How To · Linux · Solution to Error

How To Compress a Directory with the tar Command and Exclude Certain Files, tarball exclude files

When creating a tar-ball (compressing a directory of files), you may exclude certain files by using the –exclude flag.

The –exclude flag will also work with a wild card “*”. Here is an example of how to tar-ball a directory from the parent directory and exclude certain files:

IMPORTANT: Be sure to use the –exclude just after the tar command, NOT at the end of the command.