pwdeath - ssh keys for everyone

April 06, 2011

How many times a day do you see something like this?


$ ssh sam@drasticcode.com
sam@drasticcode.com's password:

Well f**k that. Typing in ssh passwords is for suckers. Personally I try to never do it, and to make it easier I have a pwdeath script to make setting up ssh keys painlessly easy. Once you’ve generated ssh keys (you can do this with ssh-keygen) put this script in your PATH.


#!/bin/bash

key=`cat ~/.ssh/id_rsa.pub`
for host in $*; do
  ssh $host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod -R 600 ~/.ssh/* && echo '$key' >> ~/.ssh/authorized_keys" 
done

Then you invoke it like this:


$ pwdeath sam@server1.com sam@server2.com

Type your password once for each server, then never type it again. Your fingers will thank you.