Skip to content

Instantly share code, notes, and snippets.

@leeky
Forked from fcoury/ghkey.rb
Created May 12, 2009 10:07
Show Gist options
  • Select an option

  • Save leeky/110408 to your computer and use it in GitHub Desktop.

Select an option

Save leeky/110408 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'octopi'
require 'socket'
include Octopi
pubkey = "#{ENV['HOME']}/.ssh/id_rsa.pub"
if !File.exist?(pubkey)
`ssh-keygen -t rsa -N ""`
end
authenticated do |g|
File.open(pubkey, 'r') do |f|
sshkey = f.read
end
g.user.add_key Socket.hostname, sshkey
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment