ssh-locate 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ rvm: 1.9.2
2
+
data/Gemfile CHANGED
@@ -3,11 +3,12 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :dev do
6
+ gem "rake"
6
7
  gem "guard"
7
8
  gem "rb-inotify"
8
9
  gem "libnotify"
9
10
  gem "cucumber"
10
- gem "aruba", git: "git@github.com:ameuret/aruba.git"
11
+ gem "aruba", git: "git://github.com/ameuret/aruba.git"
11
12
  gem "guard-cucumber"
12
13
  end
13
14
 
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  ssh-locate
2
2
  ==========
3
-
3
+ [![Build Status](https://secure.travis-ci.org/ameuret/ssh-locate.png)](http://travis-ci.org/ameuret/ssh-locate)
4
+
4
5
  A command line tool that helps you locate and contact a SSH agent launched in a separate session.
5
6
 
6
7
  Features
@@ -25,9 +26,9 @@ Launch your SSH agent and tell it to use a specific socket file with the -a opti
25
26
 
26
27
  ssh-agent -a /tmp/deployer-38us9f
27
28
 
28
- In a later shell (or any process running for the user owning the agent):
29
+ In a later shell (or any process running for the user who owns the agent):
29
30
 
30
- $ eval ssh-locate
31
+ $ eval `ssh-locate`
31
32
  Agent pid 13457
32
33
 
33
34
  Caveat
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
+ require "cucumber/rake/task"
3
+
4
+ task :default => [:test]
5
+
6
+ Cucumber::Rake::Task.new(:test) do |task|
7
+ task.cucumber_opts = ["features"]
8
+ end
@@ -9,7 +9,27 @@ module Net
9
9
  include Thor::Actions
10
10
 
11
11
  def locate_agent
12
- procs=Sys::ProcTable.ps.select do
12
+ @scanner = Scanner.new
13
+ @scanner.scan
14
+ end
15
+
16
+ def print_shell_commands
17
+ return unless @scanner.found?
18
+ print "SSH_AUTH_SOCK=#{@scanner.agentSocket}; "
19
+ puts "export SSH_AUTH_SOCK;"
20
+ print "SSH_AGENT_PID=#{@scanner.agentPID}; "
21
+ puts "export SSH_AGENT_PID;"
22
+ puts "echo Agent pid #{@scanner.agentPID};"
23
+ end
24
+ end
25
+
26
+ class Scanner
27
+
28
+ attr_reader :agentSocket, :agentPID, :found
29
+
30
+ def scan
31
+ @found = false
32
+ procs = Sys::ProcTable.ps.select do
13
33
  |p|
14
34
  (p.cmdline =~ /ssh-agent/) && !(p.cmdline =~ /--session=ubuntu/) && !(p.state=='Z')
15
35
  end
@@ -17,19 +37,17 @@ module Net
17
37
  p=procs.first
18
38
  p.cmdline =~ /ssh-agent\s-a ([-.a-zA-Z0-9_\/]+)/
19
39
  return if !$~
40
+ @found = true
20
41
  @agentSocket = $1
21
42
  @agentPID = p.pid
22
43
  end
23
-
24
- def print_shell_commands
25
- return if (!@agentPID || !@agentSocket)
26
- print "SSH_AUTH_SOCK=#{@agentSocket}; "
27
- puts "export SSH_AUTH_SOCK;"
28
- print "SSH_AGENT_PID=#{@agentPID}; "
29
- puts "export SSH_AGENT_PID;"
30
- puts "echo Agent pid #{@agentPID};"
44
+
45
+ def found?
46
+ @found
31
47
  end
48
+
32
49
  end
50
+
33
51
  end
34
52
  end
35
53
  end
@@ -1,7 +1,8 @@
1
1
  module Net
2
2
  module SSH
3
3
  module Locate
4
- VERSION = "0.0.1"
4
+ # Honoring http://semver.org/
5
+ VERSION = "0.1.0"
5
6
  end
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh-locate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-05 00:00:00.000000000Z
12
+ date: 2011-12-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sys-proctable
16
- requirement: &75522350 !ruby/object:Gem::Requirement
16
+ requirement: &72542240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *75522350
24
+ version_requirements: *72542240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &75521890 !ruby/object:Gem::Requirement
27
+ requirement: &72541570 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *75521890
35
+ version_requirements: *72541570
36
36
  description: A CLI tool and its associated Ruby library that help you locate and reconnect
37
37
  to a running SSH agent. Useful in automation scenarios where multiple processes
38
38
  must repeatedly open SSH connections leveraging a one-time authentication pass
@@ -44,6 +44,7 @@ extensions: []
44
44
  extra_rdoc_files: []
45
45
  files:
46
46
  - .gitignore
47
+ - .travis.yml
47
48
  - Gemfile
48
49
  - Guardfile
49
50
  - README.md