virtualenv-burrito 2.7

Yesterday, virtualenv-burrito 2.7 was released. There are two significant changes:

  1. All Python packages in the .venvburrito directory are now inside a versioned site-packages directory. For example, if you are running Python 2.7 during the install or upgrade, all packages will now live in lib/python2.7/site-packages.
  2. The pip program is no longer user accessible (i.e., in the PATH). You could easily figure out where it’s been moved, but that’s discouraged (and unsupported).

These changes should help reduce some confusion and incompatibilities reported on the GitHub project.

To upgrade to the latest version, run: virtualenv-burrito upgrade

If you are installing for the first time, run:

curl -sL | $SHELL

GPG Key Transition

After 14 years, it’s time for a new GPG key adhering to modern standards. You can find my transition statement here. The full-text follows.

Hash: SHA1,SHA512

Wed, 02 Jul 2014 20:54:03 -0700

I am transitioning GPG keys from an old 1024-bit DSA key to a new
4096-bit RSA key. The old key will continue to be valid for some time,
but I prefer all new correspondance to be encrypted with the new key.
All future signatures will be made with the new key.

This transition document is signed with both keys to validate the

If you have signed my old key, I would appreciate signatures on my new
key as well.

The old key:

pub 1024D/C771DF0B 2000-08-24
Key fingerprint = 6846 E600 739F 3DB5 DB02 B670 FDDE 4167 C771 DF0B

The new key:

pub 4096R/4FE98E13 2014-07-03
Key fingerprint = 5D80 FC62 9CEF 8FAE 737C DDED 19A1 D142 4FE9 8E13

To fetch my new key from a public key server:

gpg --keyserver --recv-key 4FE98E13

If you've already validated my old key, you can validate the new key is
signed by my old key:

gpg --check-sigs 4FE98E13

If you are satisfied you've got the right key, I'd appreciate your
signature and upload:

gpg --sign-key 4FE98E13
gpg --keyserver --send-key 4FE98E13

- -- jeremy avnet .:. @brainsik

Version: GnuPG v1


Python cron task – exit if already running

A simple way for Python cron tasks to exit if another process is currently running. Does not use a pidfile.

Virtualenvs with different interpreters

Update 2011-09-27: Turns out virtualenv and virtualenvwrapper support this out of the box. Most of what’s written below is horrifically complex compared to just using the -p switch when you make your virtualenv. You simply need to do this:

$ mkvirtualenv -p /path/to/some/python coolname

That’ll create a new virtualenv called “coolname” that uses /path/to/some/python for it’s Python interpreter. I’ve tested this with PyPy and it worked great.

A recent comment on the original Virtualenv Burrito announcement asked whether it was possible to create virtualenvs using different Python interpreters. The answer is a cautious: yes!

When virtualenv-burrito installs virtualenv, it prevents the virtualenv command from tying itself to a specific interpreter. I wanted to be able to switch between Python versions, creating virtualenvs for each. I haven’t publicized this feature, nor made it easy to use since there may be hidden pitfalls. That said, I’ve not run into any problems.

The way it works is mkvirtualenv uses the same interpreter invoked by the python command to create the virtualenv. For example, normally when I run mkvirtualenv I get a Python 2.7 environment. Using MacPorts, I can switch from my 2.7 default to 2.6 with:

port select --set python26

Now running mkvirtualenv creates a 2.6 environment.

Regardless of what your current default Python interpreter is, once the virtualenv is made, it stays tied to the Python used during creation.

If you don’t have a nice way to switch your default Python, you can still hack it. The key is making the python command use the interpreter you want.

Elasticfox Forever

Tired of (yet again) fixing the Elasticfox Firefox extension to work with the latest version of Mozilla Firefox, I finally just made one with an absurd maximum version defined.


You can easily create one yourself. Since xpi files are zip files, it’s something like:

  1. mkdir tangerine; cd tangerine
  2. unzip /path/to/elasticfox.xpi
  3. edit install.rdf so maxVersion is 99.0
  4. zip -r9X ../elasticfox-forever.xpi .
  5. drag elasticfox-forever.xpi onto Firefox

Or cop out and click this: elasticfox-forever.xpi

Update 2011-09-23: Using * for the maxVersion still didn’t cut it so I’ve updated the article and xpi file to use a maxVersion of 99.0.

Image modified from I’m with the band by theilr. CC:by-sa.

SSH Agent Forwarding

This is part of the mini-series OpenSSH for Devs.

SSH agent forwarding let’s you lock down remote hosts while making them easier to access and use in automated ways. One co-worker succinctly describes agent forwarding as “the shit”.


Securely connect to a remote host from a remote host without a password.

laptop:~$ ssh -A
Linux host1 2.6.35-25-server #44-Ubuntu SMP Fri Jan 21 19:09:14 UTC 2011 x86_64 GNU/Linux

host1:~$ scp .
some.config                                                       100% 1612     1.6KB/s   00:00    
host1:~$ logout
Connection to closed.

Secret Agent

The SSH agent has become so integrated into our local systems many people don’t realize it’s being used. Devs use it daily to avoid having to retype their SSH key1 password every time they connect to a remote host. The typical workflow is:

  1. Login to laptop
  2. SSH to a remote host
  3. Type SSH key password into popup
  4. No more password typing

OS X SSH keypass dialog

The agent serves us by holding onto our private key and transparently authenticating to remote hosts when we connect instead of making us type a password.2

What is SSH agent forwarding?

Simply put, agent forwarding allows you to access a remote machine from a remote machine.

Let’s look at the scenario above: connect to host1 and download a file from host2. Without agent forwarding, you’re lucky if you just get to type your password again. If host2 has password authentication disabled or your account has no password set, there’s two options. Option 1: download the file from host2 to your local machine and then upload it to host1. Option 2: upload your SSH private key to host1 and authenticate to host2 using your key password. Compare these to agent forwarding where you run scp and the file is downloaded without question.

If you’ve run into this problem more than a few times, learning about agent forwarding may feel like this:

ssh -A is the shit! No more moving private keys around for chained ssh connections!! Thanks @brainsik!

Where can it take you?

The SSH agent provides a rare pairing of increased security and better user experience.

From a per-host perspective, you can disable password authentication on all your remote machines and rely on SSH keys for superior auth. Leaked passwords are no longer a vector for unauthorized access since you can’t login with them. Forget about generating random passwords for every user on every new server. If sudo access isn’t needed, don’t set a password at all. If sudo access is required you can get away with reusing passwords, keeping your devops team lean3.

From a network perspective, you ideally want your private servers only accessible via a bastion host or other intermediary. With agent forwarding, instead of this setup being a pain to get into, it’s a single command:

$ ssh -At ssh private1.internal
Linux private1 2.6.35-25-server #44-Ubuntu SMP Fri Jan 21 19:09:14 UTC 2011 x86_64 GNU/Linux

private1:~$ logout
Connection to private1.internal closed.
Connection to closed.

Use it

Agent forwarding can be turned on via the command-line by passing -A or via your SSH config by setting ForwardAgent yes.

I’d be negligent if I didn’t recommend setting this only for hosts you trust. While it’s not possible to steal a private key through an agent, it’s trivial for a malicious root user to login to remote hosts with your public key.

Is there another way you use SSH agent forwarding? You should post a comment or send me a message.

  1. This article assumes you already use an SSH key to access remote hosts. If you don’t, send me a note. If I get enough questions about SSH keys, I’ll do a writeup on them. []
  2. Some systems aren’t setup with an askpass program and the agent running in the background. In those cases, some devs will generate their SSH private key without a password to get the effect of not needing to type in their password for every SSH connection they make. Regardless of the security implications, that setup loses a beneficial feature of SSH: agent forwarding! []
  3. Buzzwords aside, having to search for a password randomly generated 2 months ago before getting on with your task is sure way to wipe stored state and kill a task’s momentum. []

SSH Config

This is part of the mini-series OpenSSH for Devs.

An SSH config let’s you set options you use often (e.g., the user to login as or the port to connect to) globally or per-host. It can save a lot of typing and helps make SSH Just Work.


Instead of typing:

ssh -p734

You can type:

ssh sencha

By having this in your ~/.ssh/config:

Host sencha
    Port 734
    User teamaster

What’s a per-user SSH config?

In your home is a .ssh directory. This is where your SSH keypair and known_hosts1 files are. This directory is not made of unicorns. Create a file named config and your SSH tools2 will use it’s settings.

If your laptop username is different than the one on your remote hosts, create it with:

User jon.postel

If you use a non-standard SSH port to avoid the bots, create it with:

Port 22022

Have different settings for different hosts? No problem. Just keep in mind the first match wins and put specific settings before generic ones:

# ancient box we never upgraded
    User oldusername
    # still on port 22

Host *        
    Port 22022
    ForwardAgent yes

# defaults for all hosts
Host *
    User bofh

It gets better

You’re probably familiar with the dance you do when connecting to a host for the first time:

$ ssh
The authenticity of host ' (' can't be established.
RSA key fingerprint is 39:9b:de:ad:9e:be:ef:95:ca:fe:1b:53:b0:00:00:b5.
Are you sure you want to continue connecting (yes/no)? 

It looks impressive, but it’s worthless. If you’re worried about man-in-the-middle attacks, there are much better things to do. Start by disabling password authentication3 and require people to have an SSH key on the server. Expecting people to check these hashes means you’ve already failed.

To get rid of the dance add something like:

Host *
    StrictHostKeyChecking no

First time connections will give you a warning, but you’ll make it in.


You can create aliases4 by using Host to match a name and HostName to say where to connect.

Host web1

The advantages over modifying /etc/hosts are you don’t need to be root and SSH will use the same host key for web1 and The disadvantage is that only SSH tools see this. For example, your browser has no idea web1 is an alias for that EC2 host. Because of this, I sometimes create both the SSH alias and hosts entry for the best of both worlds.


There are a lot of options, but these are the ones I’ve seen used most:

  • Host — Matches the hostname argument. Accepts patterns and causes options following it to apply only to hosts matching the pattern.
  • User — Username to connect with.
  • Port — Port to connect to.
  • ForwardAgent — Set to yes to turn on SSH agent forwarding.
  • StrictHostKeyChecking — Set to no to skip the “authenticity of host” dance.
  • HostName — Server to connect to. Used to create an alias from Host to another remote server.

Do you have a favorite option not mentioned here? You should post a comment or send me a message.

  1. The known_hosts file contains the keys for all the remote hosts you’ve connected to. The stored key is compared to the remote key when you connect to warn of a man-in-the-middle attack. []
  2. ssh, scp, sftp, sshfs, well-written paramiko based Python tools, and probably more. []
  3. In the server’s sshd_config set PasswordAuthentication no. Contact me if you are interested in a post on securing the SSH server. []
  4. I made this term up. There may be a better one. []

OpenSSH for Devs

There have been many surprises as I’ve moved from Sysadmin to Coder. Some of them are a product of switching contexts: what was once “common knowledge” is now “tips & tricks” (and vice versa). One tool that has regularly come up is SSH. It can be painful to watch developers jump through unnecessary hoops (over and over again) in order to access remote hosts.

In that light, presented here is a short series of posts covering useful OpenSSH features for developers. My peers and I use these everyday and it’s made our jobs easier.

Brewer’s CAP Theorem

Brewer’s CAP Theorem

Released Virtualenv Burrito 2

This Python breakfast just got tastier. A major update to the way Virtualenv Burrito works was released this weekend. There is now full support for extension points and a less hackish way of managing the packages1 under the hood.

Already have Virtualenv Burrito installed? Run this:

virtualenv-burrito upgrade

New to Virtualenv Burrito? Read about it or run this:

curl -sL | $SHELL

Virtualenv Burrito’s goal is to have a working virtualenv + virtualenvwrapper environment with just one command. Read about it on Github or see the original announcement.

  1. distribute, virtualenv, and virtualenvwrapper []