Category: tagged

  • Tags vs. Categories, my ontological classification

    When writing something I usually have a hard time categorising the content as very seldom it will fit into one single category. The solution to this may simply be adding it to more categories instead but then the category hierarchy actually breaks. Instead I definitely prefer to assign tags to content which is much more specific and does not limit you in any way, as there is really no predefined containers but instead any word in the vocabulary can be used to tag your content. During my research determining if WordPress actually had improved the categorisation system I came across an interesting piece of writing about ontology on the web which I recommend you to read through in its full length.

    The latest version of WordPress does seem to handle tags fine although there is some misconception between the tag and category idea. It is somehow mingled together to actually overlap each other although still not the same. I guess the WordPress developers are worried about legacy installations and possible issues during an upgrade path, so they keep things backwards compatible somehow.

    As you can see on this site I make no use of the categories whatsoever. I am forced by WordPress to assign any content to at least one category which I left as the default “Uncategorized”. The name is really irrelevant as I make no use of categories in the display. You may notice the tags assigned to each post just below the title where before the category was displayed.

    To make this little change depending on your theme you may have to edit a couple of files. In my own case I edited three files:

    1. page.php
    2. index.php
    3. single.php

    The change required is the same in all three files, namely replace the following snippet:

    <?php the_category(',') ?>

    with this one:

    <?php /*the_category(',')*/ the_tags( ' ', ', ', ''); ?>

    That is all. Now you will have a nice list of tags instead of the irrational categories list which does not really suit written content.

  • Google Analytics XHTML compliance

    I had to add the Google Analytics code snippet to this site and had some issues with it validating as XHTML 1.1 and MIME type application/xhtml+xml which were solved at the end.

    The snippet is divided into two pieces of <script> tags and the first part is simply a feature to avoid getting warning messages from your browser if your page was server over SSL (https://). If your site serves pages in both HTTP and HTTPS then you can achieve the same through e.g. a server side scripting language such as PHP.

    The snippet needs to be changed to the following on HTTP pages:

    <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>

    and of course on HTTPS pages use this piece:

    <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></script>

    Now the second part of the code needs to be put between CDATA tags to properly isolate it. The code will now look like this except you need to introduce your own Google Analytics ID:

    <script type="text/javascript">
    //<![CDATA[
    var pageTracker = _gat._getTracker("UA-1234567-8");
    pageTracker._initData();
    pageTracker._trackPageview();
    //]]>
    </script>

    Now you can safely run the W3 Validator without any errors caused by Google Analytics.

  • SSH passkey setup – access without password

    I have wanted to set up password less access to my SSH servers for several years, but due to laziness mainly have never got around to actually completing the process. Just now I accessed one of my hosting accounts without any password and it actually felt quite good. It is one of these things that you think to yourself “Why didn’t I just do it before!”.

    I encountered some issues even though the process is a piece of cake and takes less than five minutes to do. When searching for solutions I tend to encounter issues with out-of-date information that no longer applies to the latest versions of software normally used. It can become annoying sometimes as you may be wasting time down the wrong path.

    I will try to write it up as simple as possible for anyone who might like to give this a go. The easiest way to get started would be to simply install the entire Putty Windows installer. Currently at version 0.60 but ensure you grab the latest version available when starting.

    Once installed go to Start > Putty > PuttyGen and the key generator will open:

    PuttyGen

    Click on “Generate” and you will see a progress bar appear:

    Puttygen progress bar

    Now you need to create some randomness by hovering your mouse pointer on top of the progress bar so it slowly moves towards the end. When done you will see your public key:

    PuttyGen key generated

    Now simply enter a key passphrase you can remember which is longer than a normal password. This needs to be used to decrypt the key when used. I will later explain how you avoid having to input this long passphrase on every login, elsewise it would defeat the purpose of not wanting to repeatedly input the password. Please note the passphrase can NOT be recovered, although you may always generate a new set of private/public keys if you happen to forget it.

    Once you have entered the passphrase twice hit “Save private key” and save the file with any name in a safe location and leave PuttyGen running as we will use it again in a bit. This leads to the next step which is to launch Putty as you normally do from Start > PuTTY > PuTTY. Go to the Connection > Data tab and input the username of the SSH account:

    Putty auto-login username

    Now move down to Connection > SSH > Auth tab and only check “Attempt authentication using Pageant”. Click on the “Browse” button and locate the private key that you created before with PuttyGen:

    Putty private key

    Now you are ready to save this to your profile. Return to the first tab Session and enter your hostname and a session name to save these profile changes. Click “Save” and the “Open”:

    Putty save session

    On connecting you may receive an error about invalid keys or similar, just login as usual with your password only. Your username should have been automatically passed to the server by Putty as per your change in Putty’s configuration earlier on.

    Run the following commands:

    mkdir ~/.ssh

    vi ~/.ssh/authorized_keys

    Now Vi will open which is a text editor and we should see an empty file where we can paste in the public key you generated before. Return to your open PuttyGen and click the public key section, select ALL text and copy. This step is where I personally went wrong and only copied the bit that is highlighted initially upon the first click within the section. You have to make sure you select ALL the text:

    Puttygen wrong selectionPuttyGen correct selection of public key

    Now you need to return to your open session in Putty and paste the public key into Vi. First hit the letter “i” to insert and then right-click on the screen to paste the content. If it pasted correctly hit the “Esc” button on your keyboard followed by:

    :wq

    This should save your public key at the server and close Vi. Now check for the correct permissions by running:

    chmod 700 ~/.ssh


    chmod 600 ~/.ssh/authorized_keys

    exit

    Putty should now close and Pageant should be launched by going to Start > PuTTY > Pageant. This is a very simple utility that will store your key’s passphrase in memory until you close it again. This is needed to avoid having to type your long passphrase upon every login, the alternative being creating a key without any passphrase which is highly insecure as anyone can login to your server if they get hold of your private key.

    Simply click “Add Key” and locate your private key stored earlier. Enter your passphrase when asked and close it so it stays minimised in the traybar:

    pageant

    Now you should be able to launch PuTTy again and simply double click on your saved session profile to access your SSH server without any further user input.