ssh-keyput 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ LICENSE
2
+ =======
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2009 Christopher Sexton
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+
data/README.markdown ADDED
@@ -0,0 +1,28 @@
1
+ ssh-keyput
2
+ ==========
3
+
4
+ Copies your ssh public key to a server.
5
+
6
+ Because <i>ssh user@hostname "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"</i> is too hard to remember.
7
+
8
+ Since OS X does not have the handy "ssh-copy-id" bash script by default I wanted to add a gem that I could install easily to perform the same task.
9
+
10
+ Currently this is no more than a sh script, as it depends on a number of unix commands (like ssh and ssh-keygen). I am sure that much of this could be replace by pure ruby libraries (and then be made dependencies) but this does what I need it to and I don't have to remember complicated commands.
11
+
12
+ It is pronounced "ssssh-kaput."
13
+
14
+ INSTALL
15
+ =======
16
+
17
+ > sudo gem install csexton-ssh-keyput -s http://gems.github.com
18
+
19
+ USAGE
20
+ =====
21
+
22
+ > ssh-keyput user@example.com
23
+
24
+
25
+ COPYRIGHT
26
+ =========
27
+
28
+ Copyright (c) 2008 Christopher Sexton. See LICENSE for details.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 4
3
+ :patch: 0
4
+ :major: 0
data/bin/ssh-keyput ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # == Synopsis
4
+ # SSH Key Put Utility
5
+ #
6
+ # == Usage
7
+ # ssh-keyput [options]
8
+ #
9
+ # For help see http://github.com/csexton/ssh-keyput
10
+
11
+ require 'optparse'
12
+ require "#{File.dirname(__FILE__)}/../lib/ssh_keyput"
13
+
14
+ kp = SshKeyPut.new
15
+
16
+ o = OptionParser.new do |opts|
17
+
18
+ opts.summary_width = 25
19
+
20
+ opts.banner = "ssh-keyput (#{kp.version})\n",
21
+ " usage: ssh-keyput [options...] [user@]hostname\n"
22
+
23
+ opts.separator "Configuration:"
24
+
25
+ opts.on('-v', '--version') do
26
+ puts "ssh-keyput version #{kp.version}\n\n"
27
+ exit
28
+ end
29
+ opts.on('-h', '--help', "Print this message") do
30
+ puts "#{opts}\n"
31
+ exit
32
+ end
33
+ opts.on('-d', '--dsa', "Use the dsa cert instead of the rsa") do
34
+ kp.key_file = "#{ENV["HOME"]}/.ssh/id_dsa.pub"
35
+ end
36
+ opts.on('-G', '--generate-rsa', "Generate an rsa key by running 'ssh-keygen -t rsa'") do
37
+ system "ssh-keygen -t rsa"
38
+ exit
39
+ end
40
+ opts.on('-D', '--generate-dsa', "Generate a dsa key by running 'ssh-keygen -t dsa'") do
41
+ system "ssh-keygen -t dsa"
42
+ exit
43
+ end
44
+ opts.on('-KFILE', '--key-file FILE', "Use a specific key file. Default #{kp.key_file}") do |file|
45
+ kp.key_file = file
46
+ end
47
+
48
+ end
49
+
50
+
51
+
52
+ begin
53
+ o.parse!
54
+ kp.host = ARGV[0]
55
+ raise "Invalid Parameter" unless kp.host
56
+
57
+ kp.put_key
58
+ rescue => detail
59
+ puts detail
60
+ puts "#{o}"
61
+ exit
62
+ end
63
+
64
+
data/lib/ssh_keyput.rb ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'yaml'
5
+ require 'fileutils'
6
+
7
+ class SshKeyPut
8
+
9
+ attr_accessor :host, :key_file
10
+
11
+ def initialize
12
+ @key_file = "#{ENV["HOME"]}/.ssh/id_rsa.pub"
13
+ end
14
+
15
+ def version
16
+ v = YAML.load_file "#{File.dirname(__FILE__)}/../VERSION.yml"
17
+ "#{v[:major]}.#{v[:minor]}.#{v[:patch]}"
18
+ end
19
+
20
+ def put_key
21
+ unless (File.exists? @key_file)
22
+ puts "No key found, please run ssh-keyput --generate to make one"
23
+ end
24
+
25
+ #read in the key
26
+ key_code = File.open(@key_file).read.strip
27
+
28
+ system "ssh #{@host} \"mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo '#{key_code}' >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys\""
29
+ end
30
+
31
+ end
32
+
33
+
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class SshKeyputTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'ssh_keyput'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssh-keyput
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Sexton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-26 00:00:00 -04:00
13
+ default_executable: ssh-keyput
14
+ dependencies: []
15
+
16
+ description: The easy to remember way to upload a public key for ssh
17
+ email: csexton@gmail.com
18
+ executables:
19
+ - ssh-keyput
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.markdown
25
+ files:
26
+ - README.markdown
27
+ - VERSION.yml
28
+ - bin/ssh-keyput
29
+ - lib/ssh_keyput.rb
30
+ - test/ssh_keyput_test.rb
31
+ - test/test_helper.rb
32
+ - LICENSE
33
+ has_rdoc: true
34
+ homepage: http://github.com/csexton/ssh-keyput
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project: ssh-keyput
57
+ rubygems_version: 1.3.5
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: ssh key put utility
61
+ test_files:
62
+ - test/ssh_keyput_test.rb
63
+ - test/test_helper.rb