ssh-forever 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.markdown +6 -6
- data/VERSION +1 -1
- data/bin/ssh-forever +8 -4
- data/lib/ssh-forever.rb +24 -15
- data/ssh-forever.gemspec +2 -2
- metadata +2 -2
data/History.txt
CHANGED
data/README.markdown
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Simple command to give you password-less SSH login on remote servers:
|
4
4
|
|
5
|
-
ssh-forever username@yourserver.com [-p port]
|
6
|
-
|
5
|
+
ssh-forever username@yourserver.com [-p port] [-i identity_file]
|
6
|
+
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
gem sources --add http://gemcutter.org
|
@@ -15,21 +15,21 @@ Simple command to give you password-less SSH login on remote servers:
|
|
15
15
|
You do not appear to have a public key. I expected to find one at /Users/matt/.ssh/id_rsa.pub
|
16
16
|
Would you like me to generate one? [Y/n]y
|
17
17
|
Copying your public key to the remote server. Prepare to enter your password for the last time.
|
18
|
-
mattwynne@mattwynne.net's password:
|
18
|
+
mattwynne@mattwynne.net's password:
|
19
19
|
Success. From now on you can just use plain old 'ssh'. Logging you in...
|
20
20
|
Linux broncos 2.6.29-xeon-aufs2.29-ipv6-qos-grsec #1 SMP Thu Jul 9 16:42:58 PDT 2009 x86_64
|
21
|
-
_
|
21
|
+
_
|
22
22
|
| |__ _ _ ___ _ _ __ ___ ___
|
23
23
|
| '_ \ '_/ _ \ ' \/ _/ _ (_-<
|
24
24
|
|_.__/_| \___/_||_\__\___/__/
|
25
|
-
|
25
|
+
|
26
26
|
Welcome to broncos.dreamhost.com
|
27
27
|
|
28
28
|
Any malicious and/or unauthorized activity is strictly forbidden.
|
29
29
|
All activity may be logged by DreamHost Web Hosting.
|
30
30
|
|
31
31
|
Last login: Sat Aug 15 17:24:17 2009
|
32
|
-
[broncos]$
|
32
|
+
[broncos]$
|
33
33
|
|
34
34
|
## Why
|
35
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/bin/ssh-forever
CHANGED
@@ -4,22 +4,26 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
|
4
4
|
require 'ssh-forever'
|
5
5
|
require 'optparse'
|
6
6
|
|
7
|
-
help = 'Usage: ssh-forever username@yourserver.com [-p port]'
|
7
|
+
help = 'Usage: ssh-forever username@yourserver.com [-p port] [-i identity_file]'
|
8
8
|
|
9
9
|
options = {}
|
10
10
|
OptionParser.new do |opts|
|
11
11
|
opts.banner = help
|
12
|
-
|
12
|
+
|
13
13
|
opts.on('-p', '--port [PORT]', 'port') do |port|
|
14
14
|
options[:port] = port
|
15
15
|
end
|
16
|
+
|
17
|
+
opts.on('-i', '--identity_file [IDENTITY_FILE]', 'identity_file') do |identity_file|
|
18
|
+
options[:identity_file] = identity_file
|
19
|
+
end
|
16
20
|
end.parse!
|
17
21
|
|
18
22
|
login = ARGV[0]
|
19
23
|
|
20
24
|
if login.nil?
|
21
|
-
puts help
|
25
|
+
puts help
|
22
26
|
exit 1
|
23
27
|
end
|
24
28
|
|
25
|
-
SecureShellForever.
|
29
|
+
SshForever::SecureShellForever.new(login, options).run
|
data/lib/ssh-forever.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
1
|
+
module SshForever
|
2
|
+
VERSION = '0.2.1'
|
3
|
+
|
4
|
+
class SecureShellForever
|
5
|
+
def initialize(login, options = {})
|
6
|
+
@login = login
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
4
11
|
unless File.exists?(public_key_path)
|
5
12
|
STDERR.puts "You do not appear to have a public key. I expected to find one at #{public_key_path}\n"
|
6
13
|
STDERR.print "Would you like me to generate one? [Y/n]"
|
@@ -10,20 +17,22 @@ module SecureShellForever
|
|
10
17
|
end
|
11
18
|
generate_public_key
|
12
19
|
end
|
13
|
-
|
20
|
+
|
14
21
|
args = [
|
15
22
|
' ',
|
16
|
-
("-p #{options[:port]}" if options[:port] =~ /^\d+$/)
|
23
|
+
("-p #{@options[:port]}" if @options[:port] =~ /^\d+$/)
|
17
24
|
].compact.join(' ')
|
18
|
-
|
25
|
+
|
19
26
|
puts "Copying your public key to the remote server. Prepare to enter your password for the last time."
|
20
|
-
`ssh #{login}#{args} "#{remote_command}"`
|
27
|
+
`ssh #{@login}#{args} "#{remote_command}"`
|
21
28
|
exit 1 unless $?.exitstatus == 0
|
22
|
-
|
29
|
+
|
23
30
|
puts "Success. From now on you can just use plain old 'ssh'. Logging you in..."
|
24
|
-
exec "ssh #{login}#{args}"
|
31
|
+
exec "ssh #{@login}#{args}"
|
25
32
|
end
|
26
33
|
|
34
|
+
private
|
35
|
+
|
27
36
|
def remote_command
|
28
37
|
commands = []
|
29
38
|
commands << 'mkdir -p ~/.ssh'
|
@@ -37,7 +46,7 @@ module SecureShellForever
|
|
37
46
|
def key
|
38
47
|
`cat #{public_key_path}`.strip
|
39
48
|
end
|
40
|
-
|
49
|
+
|
41
50
|
def generate_public_key
|
42
51
|
silence_stream(STDOUT) do
|
43
52
|
silence_stream(STDERR) do
|
@@ -50,16 +59,16 @@ module SecureShellForever
|
|
50
59
|
Process.wait
|
51
60
|
flunk("Oh dear. I was unable to generate your public key. Run the command 'ssh-keygen -t rsa' manually to find out why.") unless $? == 0
|
52
61
|
end
|
53
|
-
|
62
|
+
|
54
63
|
def flunk(message)
|
55
64
|
STDERR.puts message
|
56
65
|
exit 1
|
57
66
|
end
|
58
|
-
|
67
|
+
|
59
68
|
def public_key_path
|
60
|
-
File.expand_path('~/.ssh/id_rsa.pub')
|
69
|
+
File.expand_path(@options[:identity_file] || '~/.ssh/id_rsa.pub')
|
61
70
|
end
|
62
|
-
|
71
|
+
|
63
72
|
def silence_stream(stream)
|
64
73
|
old_stream = stream.dup
|
65
74
|
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
@@ -69,4 +78,4 @@ module SecureShellForever
|
|
69
78
|
stream.reopen(old_stream)
|
70
79
|
end
|
71
80
|
end
|
72
|
-
end
|
81
|
+
end
|
data/ssh-forever.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ssh-forever}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Wynne"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-27}
|
13
13
|
s.default_executable = %q{ssh-forever}
|
14
14
|
s.description = %q{Provides a replacement for the SSH command which automatically copies your public key while logging in}
|
15
15
|
s.email = %q{matt@mattwynne.net}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssh-forever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wynne
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-27 00:00:00 +01:00
|
13
13
|
default_executable: ssh-forever
|
14
14
|
dependencies: []
|
15
15
|
|