Created
September 11, 2012 08:09
-
-
Save philipjkim/3696821 to your computer and use it in GitHub Desktop.
Enables SSH connection without password authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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