Skip to content

Instantly share code, notes, and snippets.

@philipjkim
Created September 11, 2012 08:09
Show Gist options
  • Save philipjkim/3696821 to your computer and use it in GitHub Desktop.
Save philipjkim/3696821 to your computer and use it in GitHub Desktop.
Enables SSH connection without password authentication
#!/usr/bin/env ruby -w
unless ARGV[0]
puts 'Please input USERNAME@HOSTNAME for the argument.'
exit
end
pwd = `echo ~`.strip
key_file = "#{pwd}/.ssh/id_rsa.pub"
unless File.exists?(key_file)
`ssh-kygen -t rsa`
end
`ssh #{ARGV[0]} mkdir -p .ssh`
`cat #{pwd}/.ssh/id_rsa.pub | ssh #{ARGV[0]} 'cat >> .ssh/authorized_keys'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment