Skip to content

Instantly share code, notes, and snippets.

@kimoto
Created March 9, 2012 13:39
Show Gist options
  • Select an option

  • Save kimoto/2006530 to your computer and use it in GitHub Desktop.

Select an option

Save kimoto/2006530 to your computer and use it in GitHub Desktop.
Generate public key data-uri from ssh-rsa private key
#!/bin/env ruby
# encoding: utf-8
# Author: kimoto
require 'open-uri'
require 'base64'
require 'openssl'
ssh_rsa_path = File.join(ENV['HOME'], ".ssh/id_rsa")
ssh_rsa = File.read(ssh_rsa_path)
pubkey = OpenSSL::PKey::RSA.new(ssh_rsa).public_key.to_s
data_uri = "data:text/plain;charset=utf-8;base64," + Base64.encode64(pubkey).split("\n").join("")
puts open("http://tinyurl.com/api-create.php?url=#{data_uri}").read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment