Posts tagged with “”

Session Interaction with Quicksilver

Although it’s true that, on the whole, I prefer the OS X environment to that of the Ubuntu Linux environment I’ve been using at work for the last few months, the degree of that preference is not as high as I would have ever thought. Nonetheless, I have to confess that I have a tremendous preference for Gnome Do over Quicksilver for OS X. I know, that borders on blasphemy, right?

I prefer Do for a number of reasons that are beyond the intent of this post, but one reason is that I’ve been spoiled by having the ability to logout, restart, shutdown and otherwise interact with my user session. My inability to do so with Quicksilver has begun to frustrate me lately and tonight I finally figured out that Quicksilver has the same capability. Unfortunately, that capability is tucked away and obscured so that it’s not immediately obvious. Session interaction, as well as a few other nice tools, is tucked away in the Extra Scripts plugin.

Another of my frustrations with Quicksilver is the complexity of the interface, but I wanted to know what was in included with this plugin, so I dug it up in Finder. Since the plugin is really just a collection of shell scripts, it’s pretty easy to see what’s in there. Here are some of the highlights:

  • Get your current IP addresses
  • Eject and close the disk tray
  • Logout of your current session
  • Lock the screen
  • Switch to root
  • Put the computer to sleep
  • Shutdown or restart the system
  • Control the system volume
  • Empty the trash

More is available, but these are the functions that I thought were the most interesting or potentially useful to me. I can’t find a way to see a list of functions available in the Quicksilver UI, but if you’re interested you can see what’s included using Finder:

  1. Open the Quicksilver preferences
  2. Go to the Plug-ins “tab”
  3. Click the gear icon at the bottom of the window
  4. Select Show Plug-ins Folder
  5. Right click on the Extra Scripts.qsplugin “file” and select Show Package Contents
  6. Open the Resources/ExtraScripts directory
  7. Explore the subdirectories

Most of the scripts are pretty descriptively named. It should be pretty apparent what functionality they provide.

When SSH Public Key Authentication Fails

I’m no Sys Admin, but I connect to enough Unix machines often enough that enabling public key authentication is a real time saver. For those that may not know, public key authentication allows a user to login to another machine via SSH without a password. I’ve written a bit more about the technique itself in my archive. The other day, in the course of setting up authentication for several machines at work, I noticed that it worked for most of the machines but failed for a few others. After spending a little over an hour checking and double checking the files in my ~/.ssh directory, I spent another hour comparing files on the machines that weren’t working with the ones that were. Everything was precisely the same.

Except that it wasn’t. Evidently I neglected to read my own earlier post, specifically step 5. I had no idea that permissions were such a hot button, but it makes sense. The permissions on my ~/.ssh/authorized_keys file were 664. The boxes wouldn’t let me login because the file was writeable by someone other than me (at least in principle). As soon as I changed the permissions to 644, I was able to connect just fine.

Of course, I realize that this is by design and a very good thing, but I wasn’t expecting it so I stumbled over it.

Tab Completion for CDPATH on Mac

Though I’ve written several shell-related posts, I’m not a shell geek. Let’s get that out of the way right now. The shell is a tool for me and nothing more. I had used tcsh for years and years and years for no other reason than someone told me it was better than bash when I first started doing any “real” Unix work. I recently moved to bash because, frankly, I was tired of having to custom-configure every system I login to on a regular basis. Bash is the default shell for most Unix flavors and since the shell is only a tool, I saw no reason to continue spending time on customizations.

The other day when @patrick_mc dropped a link to a bash mastery article in a tweet, I saw the opportunity to learn something. Though it was hardly a masterful type article, I did learn about one thing that I didn’t know about before: CDPATH.

The details of CDPATH are outside of the scope of this post, but the gist is that it works the way that the PATH works. Type a directory and if it’s in your CDPATH, the OS will find it and change to that directory by name alone – even if the directory name isn’t in your current working directory. For example, if I’m in my home directory, I can type www and be delivered directly to /Users/me/Development/www as long as /Users/me/Development is in my CDPATH.

When I first read the article, I was at work and on my Ubuntu machine so I tried it there first by adding the following line to my /home/me/.bash_profile:

export CDPATH=.:~:~/Development

After sourcing ($ source .profile) my updated profile, I was able to jump to directories exactly as advertised. Moreover, tab completion worked brilliantly so, from my home directory, I could type cd w[TAB] and it would complete to cd www. Brilliant.

It wasn’t quite so easy on the Mac, though. I updated my .profile, but couldn’t get it to work. I thought I had a syntax error in my .profile, but after hours of trial and error, I was no closer. I pinged the #lazyweb on Twitter to ask whether it worked for others on OS X and got more than a few affirmative responses which just confused me even more. A quick chat with Brad Greenlee, though, pointed out the error of my ways. It turned out that CDPATH was working great, but I was assuming (yeah, I know) that tab completion would also work. It didn’t.

For me, something like CDPATH is only useful with tab completion because otherwise, I can tab complete the full path to the file before I can type the entire directory name (for all but the shortest directory names). Besides, the Tab key is completely woven into the fabric of my muscle memory now. I can’t give it up when I’m in the shell. After a little digging, I found the answer:

$ sudo port install bash-completion

Yep, that’s it (assuming you have MacPorts installed). Well, almost. You do have to update your .profile (or .bash_profile, .bashrc, etc.) to source the installed file at /opt/local/etc/bash_completion. Instructions for doing so are printed in the output of the installation. In case you close your window too early, though:

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

Happy completing.

SSH Host Key Checking

One of the things that’s always annoyed me, but not to such a degree that I’ve felt compelled to expend any effort “fixing” it, is the prompt that I get every time I SSH to a machine that I haven’t connected to before. It looks a little something like this:

The authenticity of host 'host.domain.tld (192.168.1.16)' can't be established.
RSA key fingerprint is 58:3d:dc:39:b3:5c:44:0b:ah:9b:7d:01:8e:f2:f8:77.
Are you sure you want to continue connecting (yes/no)?

Because it’s not a huge deal to type “yes” to create the connection, I’ve never cared enough to really look into it.

This morning, though, I was trying to do a pull from one of my git repositories only to find that the server signature had changed and my connection was terminated. As far as I know, the only way to re-establish a connection terminated for this reason is to remove that server from my list of known hosts. To do so I usually crack open my ~/.ssh/known_hosts file, find the line that begins with the host name of the server I’m trying to connect to and delete that line. The next time I try to connect, the server is added back to the file (after typing “yes” again).

Unfortunately, I was working on my Linux machine this morning and I got an unpleasant surprise when I opened my ~/.ssh/known_hosts file. Ubuntu, unlike every other Unix flavor I’ve worked with/in, encrypts the contents of that file. That meant I couldn’t find the line for the particular server whose signature changed for the purpose of surgical deletion. To reset that server as a known host, I’d have to delete the entire contents of the file. I connect to a number of servers and this has become a big file; I didn’t want to have to type “yes” that many times so a “fixing” the annoyance took on a greater urgency.

This is when it’s really handy to work with a Linux sys admin. He heard me expressing my annoyance in a semi-colorful manner and told me to just shut off the authentication prompt. Hearing the ability to kill two birds with one stone, I did a quick search, then cracked open my SSH config file (/etc/ssh/ssh_config) and edited the following line:

# StrictHostKeyChecking ask

I uncommented the line and changed the value to “no” and I’m no longer prompted when connecting to new machines. Now it’s safe to clear my known_hosts file without bother. I do still get a warning that a new host has been added to my file (which is nice), but no interaction is required.

Make Linux Just a Little Sexier

Granted, I’m a Mac user, at least at home, but I like to think I’m not a total fanboy. When I moved to Linux at work and began customizing my machine, I saw countless recipes with instructions for skinning Linux to look like a Mac (or maybe there’s just one and everyone in the free world is linking to it). I don’t get that. Linux isn’t a Mac. A penguin in a tux is still a penguin, right? The fact is, I like my operating systems to look like what they are and, besides, I’ve never had much luck with Linux themes. There’s always something that gets left out and kind of ruins the whole effect.

The honest truth is, I kind of like the Linux aesthetic. Most of it, anyway. I’m not, however, a fan of the default fonts and I thought that installing Mac fonts might be just the thing to dress up the penguin without overdoing it. Turns out that they are.

Try it. Here are my settings:

My Ubuntu font settings

← Earlier Posts Page 1 of 4