SSH to an EC2 Instance via Alfred

This may a task limited to me, but in case it’s not, here’s my goal:

  1. I have a collection of identical Amazon EC2 instances, all sharing the same “name” tag for identification; together they make up a Drupal server farm for a single site.
  2. I want to SSH to one of the instances – it doesn’t matter which one – so that I can execute some drush commands.

Heretofore my procedure has been cumbersome, involving logging in to the EC2 dashboard on the web, filtering my long list of instances by name, copying the external DNS name from one of the instance to the clipboard, and then pasting this, as part of an SSH command, to the terminal.

What I’ve done to streamline this, using Alfred and the AWS CLI, is this:

I set up an Alfred workflow, with the trigger keyword d7:

Alfred App Workflow Setup

The workflow triggers a Terminal command:

ssh -t -p 22 -i 'keypair.pem' \
ec2-user@`aws ec2 describe-instances --profile clientname --filters "Name=tag:Name,Values=name-filter"  \
--output text \
--query 'Reservations[*].Instances[*].PublicDnsName' | tail -n 1` \
"sudo su - apache"

Where, in my case, the components of the above are:

  • keypair.pem is the name of the EC2 keypair I used with SSH to login to the instance
  • ec2-user is the username I want to use to SSH to the instance
  • clientname is an AWS CLI profile name that provides credentials
  • name-filter is the name that the pool of instances I want to select from share in common

This command has the effect of using the AWS CLI to look up the external DNS names of all of the instances in this pool, grabbing the last one, and then SSHing to that instances and su’ing to the apache user.

So now I just trigger Alfred (Control + Space) and type d7 and press ENTER. Presto.

Alfred Workflow

All of this presupposes that you’ve already set up the AWS CLI and ensured it’s working for you.

Art in the Open 2015

Oliver and I enjoyed another excellent iteration of Art in the Open, Charlottetown’s yearly end-of-summer outdoor site-specific art-infused celebration.

There were houses in trees, and surround-sound circles, and cocoon hammocks, and visualizations of magnetic vs. true north. There were crows, of course, and sewing machine art, and tin types, and buildings made out of recycled materials, and a Morse code booth.

Each was my favourite, in its own way.

My favourite experience of the evening, though, was sitting around a fire with Oliver and Ethan at the end of the long, perfect, summer day in Victoria Park, under a reddish full Moon.

Duncan, Nardag, Morty, Hooper

There is notice in this week’s Royal Gazette that a person with middle name Nicole has changed it to Cole. Changing your name isn’t the most difficult thing to do, but it involves paperwork, and a $185 fee. I wonder what it is about the “Ni” that prompted this desire for change.

Oliver has two middle names, Duncan and Lowell.

Lowell he came by honestly.

Duncan he came by because of a misunderstanding.

Our friend Wendy had a baby boy a month before Oliver was born, and named him Dillon. But when Catherine heard the news, and the name, she mis-remembered this as Duncan and that’s what she told me his name was.

A few days later, when we learned the truth of the matter, and that Duncan was, so to speak, on the market again, we snapped it up as a middle name for Oliver.

A similar happenstance gave me to understand that our friends Bob and Yvonne had a baby girl they’d chosen to name Nardag.

I thought this an unusual choice, but who was I to call it into question. So I enthusiastically embraced it.

A few days later, when we learned the truth of the matter – that Nardag was, in fact, named Nadja – I had a hard time coping with the change, so enthusiastically had been my embrace.

To the point where I have continued to refer to Nadja as Nardag in the intervening years.

I did the same thing with roommates my brother Steve had back when he was a young lad living in Toronto.

His roommates had actual names, I’m sure; but to me they were always Morty and Hooper.

All of which is a roundabout way of saying that Nardag Nadja lands on Prince Edward Island today, a fully-formed adult, where she and a group of friends will occupy our back yard – or perhaps our living room, if it rains – for the night before heading out on a camping adventure in the Island’s hinterlands.

And, tomorrow, my brother Steve and his family land on the Island too – presumably without Morty or Hooper – for a fun-filled family vacation.

I will try very hard to keep their names straight.


Here is the front page of the New York Times from July 2, 1978, an auspicious day for the paper as it was the last day that the paper was composed from hot metal type using Linotype and Ludlow machines:

New York Times - July 2, 1978

The story of that final day is well-told in the film Farewell – ETAOIN SHRDLU, which has been digitized by and made available online.

The last act of the film, started at about 22:36 cover the mechanics of the post-hot-metal newspaper page composition process – a trade that I apprenticed in 1990 – using the paper of March 2, 1980 as an example.

Here’s a still from the film showing that edition’s front page on the paste up board:

New York Times - March 2, 1980 - in paste up

And here’s that same page, as it’s available today on the New York Times website:

New York Times front - March 2, 1980

The phototypesetting process that the Times graduated to in 1978 is a process I once knew backward and forward: from 1991 to 1993 it was the trade I learned at the Peterborough Examiner.

What you see the printers in the film doing – keyboarding text, operating a phototypesetting machine, trimming the developed result, waxing and pasting up, with an editor at the shoulder – was the stuff of my everyday life for almost two years (an abbreviated apprenticeship, given historical practice, as I came to the position with some digital and keyboarding skills).

What’s interesting, looking back 37 years after the moved from hot type to cold, is that the reaction of the hardened old printers in the film to the transition is much the same reaction I had when, only a few months after I left my paper, there was a transition from phototypesetting and paste-up to completely digital pagination.

While this could be chalked up simply to nostalgia, I think there’s something to be said for the old ways: the interplay between page editor and printer that you see in the film a 9:40 is a relationship I know very well, and the film does a good job at describing and demonstrating how symbiotic a partnership it was:

The closest cooperation is needed, between the page editor and the makeup; together, they almost talk the type into the page form, coax it, cajole it, make it fit, as they work against the clock.

With the transition from hot type to cold type to digital, that “closest cooperation” has been diminished and then diminished again. It’s still there in some form, but the physical aspect of it – coax it, cajole it, make it fit – is gone now, and with it the “talking the type,” the patter between printer and editor that went with it. I’ve always held that those conversations were the heart of the newspaper.

Which is why I shed a tear or two watching Farewell ETAOIN SHRDLU: it’s a look at the wake for both a technology and an approach to newspapering, neither of which will ever return.

O'Neil Home Gallery (or "oh, look, a café right where we need it!")

Yesterday was an unusual one for me and Catherine: Oliver was off with Derrick camping and Cloggerooing and so we were left to our own devices as a couple. It was like 1998 all over again.

Sitting in the living room after breakfast we tried to come up with a plan for the day.

“Should we just go to work?”, asked Catherine.

That was a trick question. I knew it.

“No, of course not!”, I replied.

Which was the desired response.

And so we bundled our towels and swimsuits and beach chairs into the recently-air-conditioning-free Jetta (my mechanic reported last week that the AC was shot, and the repairs would likely bankrupt me) and headed west.

We stopped for lunch at Scapes in Borden-Carleton (fish cakes and salad; fantastic) and for iced coffee at Samuel’s in Summerside, thus recreating a trip that Oliver and I took earlier in the summer.

But when we got to Kensington, instead of heading back to town, we took the Malpeque turn instead, and headed for Cabot Beach Provincial Park, the hour – about 3:30 p.m. – being appropriate for a swim, especially after driving around all day in a car cooled only by the open windows blowing hot air over us.

I am not a natural beach goer. The logistics of a day at the beach, combined with a general unease with sand, and a vague underlying jellyfish phobia mean that while I’m not completely beach-averse, I won’t put my hand up when there’s a call for beach volunteers.

But yesterday, if there was ever a day to get over all that, was the day. And so I did.


We spent a very pleasant few hours at the beach, alternating between paddling about in the shallow, cool, low tide water and staring out at the shallow, cool, low tide water. It was the perfect antidote to the summer heat, and made me wonder why I don’t go to the beach every day.

Heading out of Cabot Beach toward Malpeque, we mused about where we should have supper. We’d been to all the usual suspects this summer, and nothing jumped out at us.

“Maybe we should just go home?”, Catherine suggested.

That was a trick question. I knew it.

No sooner were to the words out of her mouth than I spotted a sandwich board in downtown Malpeque: Artisan Café, with an arrow pointing east.

I turned east.

And there, 50 feet from the sign, was O’Neil Home Gallery, still open, and serving food on what looked like a breezy, cool porch.

O'Neil Home Gallery in Malpeque

It was as if the fates conspired to drop exactly the thing we were looking for exactly into the space we were looking for it to be in.

We alighted the breezy porch and I knew we were in the right place when, upon my asking “do you have iced tea?”, our server replied “well, I can certainly make you one”, emerging a few moments later with this:

O'Neil Home Gallery Iced Tea

We then enjoyed a tasty meal: Catherine had a substantial lobster roll, and I had the gnocchi with pesto accompanied by a salad.

Thus sated, we motored off back home, stopped at the PEI Preserve Company for dessert en route.

We arrived home about 8:00 p.m. and about an hour later our very tired Oliver arrived home from his weekend in the sun.

A good time was had by all.