Skip to content

Testing new ssh keys

You created a new ssh key, but are you actually testing it?


I routinely have to create new ssh keys for system users and also verify that they are working correctly. One possible area of confusion is how ssh keys are found by the ssh client.

While most of this information is not specific to osx, since I typically use a macbook running osx, I'll cover a couple of things somewhat specific to osx.

SSH clients will typically default to searching for a private key that exists in the user's home directory in a subdirectory named ".ssh"

So let's assume that you create an ssh key for a new user, utilizing ssh-keygen


ssh-keygen -t ed25519 -N some-new-passphrase -f id_newuser -C "new user"
 


Should you omit the -N parameter above you will be prompted for a passphrase. In either case, you should use passphrases in almost all situations to protect your system from lost or stolen private keys!!!

So if all goes well, you will now have a new public/private ssh key pair.

On the remote system, you will typically add the public key (id_newuser.pub in this example) to the .ssh/authorized_keys file.

While not the point of this article, you will also need to understand the permission requirements of the user's home .ssh directory and files. Make sure the directory and files are private to the user, or ssh connections will fail.

Time to test

Continue reading "Testing new ssh keys"

Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this

In the process of upgrading a Symfony project from version 2 to version 5, I came across an issue with a MySQL table that has a number of BIGINT columns. There had been no issue previously, but after updating to the newer symfony (and doctrine components) mySQL bigint columns were empty/null in my doctrine entities.

After some investigation I came upon this section of the Doctrine manual:

For compatibility reasons this type is not converted to an integer as PHP can only represent big integer values as real integers on systems with a 64-bit architecture and would fall back to approximated float values otherwise which could lead to false assumptions in applications.


To protect symfony apps running on 32 bit systems, Doctrine maps Bigint columns to the string type, and this broke the entity definition I was using, even though my application will only be deployed on 64 bit systems. I think that for most people this is the norm.

There are a few different ways to get around this issue, including type casting from string to integer/integer to string in your getters and setters, but if you have a lot of bigint columns across tables, that probably isn't a great solution. In this article, I present the solution I implemented, which utilizes a Custom Doctrine type to override the built in Doctrine behavior.
Continue reading "Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this"

docker4lamp - A LAMP Docker development environment

I have made this project (Docker For LAMP) publically available on Github, under the MIT license.

The target user group is php developers who want or need a simple, minimal (yet very current) LAMP development environment. I want this to be friendly to new developers, and a useful alternative to localhost environments like xamp, mamp or wamp.

Ideally it offers the type of convenience and isolation of a vagrant lamp environment except with orchestrated containers. Continue reading "docker4lamp - A LAMP Docker development environment"

Symfony 5.2 and Apache 2.4

Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a number of years nginx with php-fpm was the preference for many sysadmins seeking to wring the maximum performance out of a webserver that also has to run php scripts, but there are now simple ways of configuring apache to use php-fpm while achieving comparable performance to nginx.

For example a vhost setting like this one is possible:


<VirtualHost *:80>
    SetEnv ENVIRONMENT "dev"
    <FilesMatch \.php$>
        SetHandler proxy:fcgi://php:9000
        # for Unix sockets, Apache 2.4.10 or higher
    </FilesMatch>
    # Proxy .php requests to port 9000 of the php-fpm container
    DocumentRoot /usr/local/apache2/cms/public
    ServerName cms.mydev.local
    ServerAdmin [email protected]

    <Directory /usr/local/apache2/cms/public>
        DirectoryIndex index.php index.html
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
   
    # Send apache logs to stdout and stderr
    CustomLog /proc/self/fd/1 common
    ErrorLog /proc/self/fd/2
</VirtualHost>
 


Continue reading "Symfony 5.2 and Apache 2.4"

Symfony 5: The Fast Track book and installing a local PHP version that works!

Having backed Fabien Potencier's "Symfony 5: The Fast Track" book on Kickstarter, I received the book a few weeks ago, and had a chance over the weekend to start reading it.

As a Macbook/OSX user, his recommended environment includes a current locally installed version of PHP with a number of php extension libraries. You also need installation of the php standard composer tool, as well as docker. As I have a Macbook running OSX Mojave, I had to take a number of steps to be able to get started following the book and getting a working installation of the guestbook project using the book's recipe. Here's what I did:


Continue reading "Symfony 5: The Fast Track book and installing a local PHP version that works!"

Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'

So you have a private Bitbucket Repo and you want to utilize it in your project composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "Invalid OAuth consumer provided"

Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'"