direct_ssh 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +77 -4
- data/bin/direct_ssh +2 -2
- data/direct_ssh.gemspec +1 -1
- data/lib/direct_ssh/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# DirectSsh
|
2
2
|
|
3
|
-
In order to use ssh without the need to enter password everytime,
|
4
|
-
this gem will create public/private rsa keys if they do not exist
|
5
|
-
and send public key to remote server
|
3
|
+
In order to use ssh without the need to enter password everytime, this gem will create public/private rsa keys if they do not exist and send public key to remote server
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,7 +18,82 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
## Usage
|
22
20
|
|
23
|
-
|
21
|
+
Scripts like these
|
22
|
+
|
23
|
+
a. scripts which ask password everytime
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
#!/usr/bin/env ruby
|
27
|
+
# encoding: UTF-8
|
28
|
+
|
29
|
+
require 'net/ssh'
|
30
|
+
require 'highline/import'
|
31
|
+
|
32
|
+
host = '127.0.0.1'
|
33
|
+
user = 'user'
|
34
|
+
|
35
|
+
options = {}
|
36
|
+
options[:password] = ask("#{user}@#{host}'s password: ") { |q| q.echo = false }
|
37
|
+
|
38
|
+
Net::SSH.start(host, user, options) { |ssh|
|
39
|
+
puts ssh.exec!('cat /etc/*-release')
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
43
|
+
b. scripts which expose password directly
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
#!/usr/bin/env ruby
|
47
|
+
# encoding: UTF-8
|
48
|
+
|
49
|
+
require 'net/ssh'
|
50
|
+
require 'highline/import'
|
51
|
+
|
52
|
+
Net::SSH.start('127.0.0.1', 'user', {:password => 'password'}) { |ssh|
|
53
|
+
puts ssh.exec!('cat /etc/*-release')
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
can be rewritten like this
|
58
|
+
|
59
|
+
c. direct_ssh example with block form
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
#!/usr/bin/env ruby
|
63
|
+
# encoding: UTF-8
|
64
|
+
|
65
|
+
require 'direct_ssh'
|
66
|
+
|
67
|
+
DirectSsh.start('127.0.0.1', 'user') { |ssh|
|
68
|
+
puts ssh.exec!('cat /etc/*-release')
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
or
|
73
|
+
|
74
|
+
d. direct_ssh example without block
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
#!/usr/bin/env ruby
|
78
|
+
# encoding: UTF-8
|
79
|
+
|
80
|
+
require 'direct_ssh'
|
81
|
+
|
82
|
+
ssh = DirectSsh.start('127.0.0.1', 'user')
|
83
|
+
puts ssh.exec!('cat /etc/*-release')
|
84
|
+
ssh.close
|
85
|
+
```
|
86
|
+
|
87
|
+
## Shell
|
88
|
+
|
89
|
+
The direct_ssh shell command checks status of ssh connection to the remote server. It will ask password and send public key to remote server if neccessary.
|
90
|
+
|
91
|
+
After ssh connection created successfully, The `cat /etc/*-release` command will be executed.
|
92
|
+
|
93
|
+
```text
|
94
|
+
Usage: direct_ssh user@host [-p port]
|
95
|
+
- default port 22 will be used if you leave it off
|
96
|
+
```
|
24
97
|
|
25
98
|
## Contributing
|
26
99
|
|
data/bin/direct_ssh
CHANGED
@@ -6,8 +6,8 @@ require 'direct_ssh'
|
|
6
6
|
require 'net/ssh'
|
7
7
|
|
8
8
|
def usage
|
9
|
-
puts '
|
10
|
-
puts '
|
9
|
+
puts 'Usage: direct_ssh user@host [-p port]'
|
10
|
+
puts ' - default port 22 will be used if you leave it off'
|
11
11
|
end
|
12
12
|
|
13
13
|
def parse_args(argv)
|
data/direct_ssh.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.email = ["xxjapp@gmail.com"]
|
13
13
|
spec.description = %q{Create public/private rsa keys if they do not exist and send public key to remote server}
|
14
14
|
spec.summary = %q{Use ssh without the need to enter password everytime}
|
15
|
-
spec.homepage = %q{
|
15
|
+
spec.homepage = %q{https://github.com/xxjapp/direct_ssh}
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
18
|
spec.files = `git ls-files`.split($/)
|
data/lib/direct_ssh/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: direct_ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -95,7 +95,7 @@ files:
|
|
95
95
|
- lib/direct_ssh/key_handler.rb
|
96
96
|
- lib/direct_ssh/validator.rb
|
97
97
|
- lib/direct_ssh/version.rb
|
98
|
-
homepage:
|
98
|
+
homepage: https://github.com/xxjapp/direct_ssh
|
99
99
|
licenses:
|
100
100
|
- MIT
|
101
101
|
post_install_message:
|