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.

Sunday, April 13, 2008

extract a range of lines from a file

problem:
You want to extract a range of lines from a file

solution:
sed comes to the rescue here! the following would print the line range from filename to stdout
sed -n '5,8p;8q' filename
5 = from line 5, including 5
8p = to line 8 including 8
8q = stop processing and quit

citation:
http://linuxactivist.blogspot.com

native overburning in os x

problem:
You have object(s) over 700mb you want to burn in os x, using Finder, on a 700mb CD-R

impact:
You can't burn it, Finder tells you you need larger media

solution:
For a slightly oversized dataset, say 710mb you can use overburning technique. This is a common feature of 3rd party burning tools/software. Here is a command line solution:

Create a set of folders and a shell script to suit, with the following contents:
hdiutil makehybrid -o tempfile contents_to_overburn/
hdiutil burn tempfile.iso
rm tempfile.iso
rm contents_to_overburn/*
citation:
http://www.harecoded.com