Tuesday, April 19, 2011

Tiny OS X Server Admin Hack

On my Slicehost slice, I often need sudo to restart my web server or install various things. For obvious reasons, I can't give you the literal shell alias I use in OS X Terminal for that, but I can give you a censored version.

alias slice="echo $PASSWORD | pbcopy && ssh -p $PORT_NUMBER $USERNAME@$IP_ADDRESS"

First I put the password I'll need, if I use sudo, into the OS X clipboard using pbcopy; then I ssh into the server as normal. When Ubuntu asks me my password, I just hit ⌘-V. And boom. It just works.