Thursday, December 9, 2010

Generating passwords at the command line

I posted this gem over at Stack Overflow for generating random passwords on the Linux command line.
echo $(</dev/urandom tr -dc A-Za-z0-9 | head -c8)
Enjoy

Kudos to aigark's share

Monday, December 6, 2010

iTunes is out of sync with ID3 tags

problem: iTunes is out of sync with ID3 tags

  • You've used a tool to manage your MP3 ID3 tags and iTunes is out of sync with the changes
  • You would like to refresh ID3 tags on selected tracks in iTunes or your entire iTunes Library

    impact: grrrrrr

    This is rather frustrating, all that hard work to manage your tags and iTunes gives you the middle finger and your ID3 tags are out of date...

    solution:

    This should work for _ALL_ iTunes versions up to the time of writing, which is 10.1.
    In theory it should also work on all platforms too.
    1. First off, close iTunes if open, make sure its dead
    2. Make sure the tracks you want to work with are not read only
      You can protect iTunes from modifying your tracks by settings files to read only
    3. Open iTunes
    4. Select the tracks that you want to refresh
      You can select _ALL_ but be warned the more you select, the longer the process will take. I strongly suggest being selective, at least until you've mastered the technique
    5. With the tracks selected press CTRL+I
      You can also right click or activate the context menu and click "Get Info"
    6. Make sure NO checkboxes are checked
    7. Select the sorting tab
    8. Enter anything you like into a blank sorting field
      This will check the checkbox for the specific field
    9. Double check only the sorting checkbox is selected
    10. Click OK
    11. iTunes will show a progress bar as it applies changes
    12. You should see the tracks now have the latest ID3 tags
    13. Repeat to remove the sort tag when your happy
    Note a positive side effect of this operation... any missing files that were selected will now have the exclamation mark next to it, might be helpful to some :)

      citation:

      I've combined methods from these pages
      Props to Kishore @ Chinto's blog
      and Yoricko @ Harmonic Mixing Community

      Wednesday, September 22, 2010

      Force a LAN DHCP lease to renew

      If your having issues with an existing lease, perhaps an ip conflict... and you want to force your windows DHCP client to get a new IP address then try the following:
      1. ipconfig /release
      2. reboot
      This has worked for me on Windows 7, so it probably works on recent windows versions too.

      A simple ipconfig /release and ipconfig /renew doesn't cut the mustard in most cases...

      No idea if this would work for a WAN lease, worth a try I guess.

      Sunday, September 12, 2010

      Automating ssh public key authentication with keys that have passphrases

      This subject has burnt a day of my time this week... upon re-reviewing man ssh-add I should of got to solution much quicker. At first I was annoyed and the lack of documentation... perhaps now I'm just annoyed at how its written... because I failed to read it thoroughly enough the first time!

      Enough rambling.

      A large amount of my automation with bash involves remote host execution... most scripts I deal with require humans to do something like:

      $ eval $(ssh-agent); ssh-add ~/.ssh/some-key
      ... enter some password if the key has one
      $ ./some_script $servers $work

      Where $servers is a file or list of hosts to be affected and $work gives the script an indication or direct instruction on what to perform on the remote hosts. a simple example of ./some_script:

      #!/bin/bash
      servers=$1;work=$2
      for $server in $servers; do
      ssh $user@$server "$work"
      done

      For some scripts, the time had come to make them part of a workflow and automate them further... the the scripts had to run completely autonomously and return the result of their execution to the workflow.

      So, due to a number of factors, time being a big one, I decided to look at how to input a password to authenticate the remote access. I know this has security implications but it is what it is for now... to be improved in time.

      I wanted to avoid having to use the expect command and I wanted to keep the existing authentication keys. So I set about the manuals for ssh, ssh-agent and ssh-add.

      Up popped $SSH_ASKPASS... The primary mistake I made which burnt most of my time researching this... was not realising $SSH_ASKPASS ONLY applies to passphrases from public key authentication. It does not apply to interactive password authentication.
      In layman's terms $SSH_ASKPASS provides the path to the executable that will output the passphrase for the given key.

      So with that cleared up, my solution looks like this:

      # setup env
      $ export DISPLAY=none SSH_ASKPASS=/home/$user/output_phasephrase.sh;
      # create authenticated session
      $ eval $(ssh-agent); ssh-add /home/$user/.ssh/some-key < /dev/null

      First set up the env for ssh-add and secondly add the key. After the key is added successfully, the shell/script session is fully authenticated for any remote hosts that recognise the key.

      The output_passphrase.sh can be as simple or as complicated as you'd like. For example:

      #!/bin/bash
      echo 'some-passphrase'

      Would work but has security implications! Something like this would be better:

      #!/bin/bash
      sudo gpg -d /home/$user/key-passphrase.txt.gpg 2> /dev/null

      Monday, August 9, 2010

      problem:
      You're using Outlook 2010 with an exchange account, full 'non instant' search and indexing is working as expected, however instant search and "search tools" options/buttons are disabled/grayed out!

      impact:
      counter productive and annoying, prevents fast searching and requires much more typing to yield results.

      solution:
      Ensure you're exchange account is using "cached mode" under the account settings

      Wednesday, November 11, 2009

      Hardware solutions for Apples Time Machine software

      I was given the challenge to discover "hardware options" for use with Apples Time Machine software. The solution had to support multiple MAC's, not necessarily simultaneously.

      I Googled around to learn more about the Time Machine software to figure out what plays well with Apples backup solution.

      The most concise and extremely useful FAQ I found was on the Apple discussion forums: Time Machine: Frequently Asked Questions. Kudos to Author: Pondini

      Also useful was:

      Best target device?

      Check out the mentioned FAQ for the full "officially supported" target device list. For my situation I'm going to focus on two solutions:

      • An external disk (USB or FireWire)
      • A Time Capsule

      The most cost effective option would have to be the external disk. At the time of writing you can pick up say a 1TB Seagate external solution at ~0.06 pence (GBP) per GB.

      Then there is the Time Capsule option, which comes in 1TB and 2TB flavours. At the time of writing that's 0.23 and 0.38 pence (GBP) per GB respectively.

      So is the minimum 65% price per GB increase worth it for the wireless Time Capsule option? Let's have a look in depth at the two solutions and what they offer.

      External Hard Drive solution in depth

      Pro's

      Con's

      Cost effective

      Inflexible for portables, backups can only be transferred to repository when the drive is physically connected

      Fastest data transfer

      Multiple sources are supported but simultaneous backup is NOT possible due to physical limitations of a single device

      Time Capsule solution in depth

      Pro's

      Con's

      Very flexible and convenient

      Not the option when cost is the primary concern

      Setup and forget factor

      Even though 802.11n and dual-band is supported it's never going to be as fast or consistent as a wired solution

      Multiple sources can be backed up simultaneously

      Wi-Fi congestion and black spots may prove frustrating.

      Wireless drive sharing out of the box, including MobileMe support

       

      Wi-Fi Print server, connect a USB printer to the capsule

       

      Multi device support, virtually all 802.11x Wi-Fi devices

       

      Conclusions

      Single Desktop User?

      If you are a single desktop user, where you primarily use your MAC on your desk then the Hard Drive is the solution for you and is also cost effective.

      Don't mind plugging in the cable regularly or on a budget?

      If you're a portable user who doesn't mind hooking up to an external device to allow Time Machine to sync it's backups OR you're just on a budget then the Hard Drive is the solution for you.

      You're looking for the "setup and forget" factor?

      If you're not fussed about cost and want the most flexible and convenient option with the "setup and forget" factor... who also doesn't mind the possibility of slower backup transfers and the usual Wi-Fi pitfalls then the Time Capsule is the solution for you. You can also take advantage of some other nifty features like wireless drive sharing and Wi-Fi print server.

      Open questions

      I'm unsure if the time capsule can be used as a "backup target" and a "shared drive" simultaneously, it's probable that these features are mutually exclusive. Maybe both features are possible if a USB hard disk was connected to the time capsule?

      It might be possible to plug a MAC directly in to a time capsule via USB to transfer backups. I've no idea if this would be transparent to the software.

      Real world solution options

      Where would my money go? If I could specify the disk manufacturer it would be Seagate. I've had years of good experience with their high capacity drives. I moved away from IBM's after having a number of failures attributed to the 'click of death' phenomenon.

      Homebrew external hard drive solution

      I would start looking at Seagate's 3.5" Barracuda hard drives and I'd drop one in to an Icy Box external enclosure. Either the IB-318StUS2-B or the IB-362StUS2-B

      Out of the box external hard drive solution

      I would start looking at Seagate's "Expansion" external drives. These come in 2.5" portable and 3.5" desktop flavours with capacity ranging from 250GB to 2TB.

      The time capsule

      Apples solution is the only officially supported option that I'm aware of which comes in 1TB and 2TB flavours.

      Where would I buy?

      I've been a long term customer and advocate of Scan.co.uk. I've actually worked for them and with them historically and I know their operation and their mindset. It's a pleasure to do business with them and I trust their pre and post sales service impeccability. Check out their Facebook page.

      Got feedback?

      Critique and feedback welcome... just leave a comment.