csexton-ssh-keyput 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
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 I depend on a number of unix commands (like ssh and ssh-keygen), but I am sure that much of this could be replace by ruby libraries (and then we could make this gem dependent on those) but this does what I need it to and I don't have to remember complicated command lines.
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: 3
3
+ :patch: 2
4
+ :major: 0
data/lib/runner.rb ADDED
@@ -0,0 +1,58 @@
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
+
13
+ module SshKeyPut
14
+ VERSION = "0.0.1"
15
+
16
+ class Runner
17
+ def self.runner
18
+ #@keyput = SshKeyPut::Base.new
19
+
20
+ self.parse_options
21
+
22
+
23
+ end
24
+
25
+ def self.parse_options
26
+ OptionParser.new do |opts|
27
+
28
+ opts.summary_width = 25
29
+
30
+ opts.banner = "ssh-keyput (#{SshKeyPut::VERSION})\n\n",
31
+ "usage: ssh-keyput [options...]\n",
32
+
33
+ opts.separator ""
34
+ opts.separator "Configuration:"
35
+
36
+ opts.on('-v', '--version') do
37
+ puts "ssh-keyput version (#{SshKeyPut::VERSION})\n\n"
38
+ exit
39
+ end
40
+ opts.on('-h', '--help') do
41
+ #RDoc::usage() #exits app
42
+ puts "#{opts}\n"
43
+ exit
44
+ end
45
+ opts.on('-V', '--verbose') do
46
+ puts "Verbose!"
47
+ end
48
+ opts.on('-r', '--generate') do
49
+ puts "Installing example .twitter_archive.yml to your home directory"
50
+ exit
51
+ end
52
+
53
+ end.parse!
54
+ end
55
+ end
56
+ end
57
+
58
+ SshKeyPut::Runner.runner
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 CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csexton-ssh-keyput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Sexton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-23 00:00:00 -08:00
12
+ date: 2009-01-24 00:00:00 -08:00
13
13
  default_executable: ssh-keyput
14
14
  dependencies: []
15
15
 
@@ -22,7 +22,13 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - README.markdown
26
+ - VERSION.yml
25
27
  - bin/ssh-keyput
28
+ - lib/runner.rb
29
+ - lib/ssh_keyput.rb
30
+ - test/ssh_keyput_test.rb
31
+ - test/test_helper.rb
26
32
  has_rdoc: true
27
33
  homepage: http://github.com/csexton/ssh-keyput
28
34
  post_install_message: