Thursday, 5 March 2009

Twittering from the terminal

Update: Found out twitter ``tinifies'' your URLs for you...

I've been twittering for 2 hours now, and thought it would be nice to detail how one can update their status from the command-line without displaying their password. A few pages helped me along:

  • Dave Taylor wrote a fine article on how to tweet using the command line,
  • Duane Odom writes about his solution to encrypting passwords, which got me on the right track for that,
  • User Heller_Barde wrote a script, tinify which is excellent for shrinking the links you'll want to add to your tweet.
  • defcon posted a guide to getting started with GPG in Ubuntu, which I mostly followed line by line.

So now to my solution, a mashing of all the bits from the articles above:

  1. Create GPG key, remember what you put for your full name as you'll need it for the next step gpg --gen-key
  2. Create encrypted twitter `username:password' string. echo "<user>:<pass>" | gpg -e -r "Your Full Name" >~/.twitter.gpg
  3. Download the tinify script (and xclip and curl, if you don't have them already)
  4. Tweet away! (Don't forget to copy the link you want tinified before running) TWITTERPASSWD=`gpg -d -r "Your Full Name" ~/.twitter.gpg` \ curl --basic --user "$TWITTERPASSWD" --data-ascii \ "status=I think #TED is pretty, pretty good: `tinify`" \ http://twitter.com/statuses/update.json

Disclaimer: I've played around with GPG and Twitter for two hours or so, and haven't yet fully thought out the security consequence of storing the plaintext username:password string as an environment variable. A shell script to encapsulate the command above would be nice too! Next post perhaps?

Peace /nzroller

No comments:

Post a Comment