loginx 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17913cf8a33a6bdcb415d76fddf9ab728800bac
4
- data.tar.gz: 917dd83345570e64b4a3a303f398427c65b6d4d0
3
+ metadata.gz: 5dda23e7ea79f069d22bd328ebd295912ef82376
4
+ data.tar.gz: 2eb59e48598ae172460675e0676e6aaaf0dfaaf9
5
5
  SHA512:
6
- metadata.gz: dd94344833eaedddc6216c5b74c2a611b6c1df6a21679fe228da400c31e5486849d629f339ff31859d3d84b6b2450b3daf278fd258761feb7e1388053ec13d40
7
- data.tar.gz: 4e35bfcac705d61497b2d620b9b676437e4fe2d3e62f57ced7609c4c4f5f7a0d6f1d1ad0c20c4fa7f27586b195407e595433572a399596a5a2a1c2a6af60f763
6
+ metadata.gz: 98ec08991c10c3794fb2289b452e08ea5ecceb437c625064ac3d56e3148be44f21906bd24c4ac82e1415eaf7394a40e95c1c0c45b456842eab6aa0e0a3aee3ce
7
+ data.tar.gz: 475bd4eadfe65d7ec5873dc0c7783a50015a9b0552b72f07ac34ad27f9a41248eb55d7821f1465546a5fb03d6645b7be3b1a1b166429c165c101455b7b9ff675
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- loginx (1.3.1)
4
+ loginx (1.3.2)
5
5
  methadone (>= 1.9.3)
6
6
  ruby_expect
7
7
 
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # Loginx
2
2
 
3
+ Loginx
4
+
3
5
  ##install
4
6
  ```
5
7
  gem install loginx
6
8
  ```
7
9
 
8
10
  ##describe
11
+
12
+
9
13
  ```
10
14
  login server quickly without entering password
11
15
  help generate rsakey
@@ -20,14 +24,17 @@ save user and port
20
24
  ~/.loginx/projects
21
25
  save server infomation
22
26
  ```
23
- ###usage
27
+ ### usage
28
+
24
29
  ```
25
30
  loginx [project_name][server_alias]|[ip]
26
31
 
27
32
  recommend configuring loginx alias---lx
28
33
 
29
34
  ```
30
- ###argvs
35
+
36
+ ### argvs
37
+
31
38
  ```
32
39
  -L list all projects
33
40
  -l [project_name] list all hosts in the project
@@ -38,12 +45,18 @@ recommend configuring loginx alias---lx
38
45
  -h/no argv help
39
46
 
40
47
  ```
41
- ###improvement
48
+
49
+ ### improvement
50
+
42
51
  ```
43
52
  add using [tab] to complete command
44
53
  password should be encrypted
45
54
  ```
46
55
 
56
+ ## details
57
+
58
+ using [`methadone`](https://github.com/davetron5000/methadone) to create Ruby console application,using [`ruby_expect`](https://github.com/abates/ruby_expect) to execute remote command
59
+
47
60
 
48
61
  ## Contributing
49
62
 
@@ -52,5 +65,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/terrys
52
65
 
53
66
  ## License
54
67
 
55
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
-
68
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/bin/loginx CHANGED
@@ -2,9 +2,9 @@
2
2
  # coding: utf-8
3
3
  require 'optparse'
4
4
  require 'methadone'
5
- require 'loginx.rb'
6
- require 'list.rb'
7
5
  require 'yaml'
6
+ require 'loginx'
7
+ require 'list.rb'
8
8
  require 'rubygems'
9
9
  require 'ruby_expect'
10
10
  require 'setuser.rb'
@@ -14,10 +14,6 @@ require 'delete.rb'
14
14
  require 'core.rb'
15
15
  require 'fileutils'
16
16
 
17
-
18
-
19
-
20
-
21
17
  class App
22
18
  include Methadone::Main
23
19
  include Methadone::CLILogging
@@ -126,5 +122,4 @@ class App
126
122
  end
127
123
 
128
124
  go!
129
-
130
125
  end
data/lib/add.rb CHANGED
@@ -2,8 +2,7 @@
2
2
  class ADD
3
3
  attr_accessor :server_alias, :ip, :password
4
4
 
5
-
6
- def initialize(server_alias,ip,password)
5
+ def initialize(server_alias, ip, password)
7
6
  self.server_alias = server_alias
8
7
  self.ip = ip
9
8
  self.password = password
@@ -12,27 +11,27 @@ class ADD
12
11
  def add_record(value)
13
12
  project_path = File.expand_path("~/.loginx/projects/")
14
13
  if Loginx::Exist.project_exist?(value)
15
- @info = {}
16
- detail = {}
17
- detail['ip'] = self.ip
18
- detail['password'] = self.password
19
- @info.store(self.server_alias,detail)
20
- @load = YAML::load(File.open("#{project_path}/#{value}.yml"))
21
- if @load.has_key?(self.server_alias)
22
- puts "the server alias already exists,will you overwrite it(y/n)"
23
- gets
24
- unless $_.chomp =='y'
25
- puts "nothing changed"
26
- exit 1
27
- end
14
+ @info = {}
15
+ detail = {}
16
+ detail['ip'] = self.ip
17
+ detail['password'] = self.password
18
+ @info.store(self.server_alias, detail)
19
+ @load = YAML::load(File.open("#{project_path}/#{value}.yml"))
20
+ if @load.has_key?(self.server_alias)
21
+ puts "the server alias already exists,will you overwrite it(y/n)"
22
+ gets
23
+ unless $_.chomp =='y'
24
+ puts "nothing changed"
25
+ exit 1
28
26
  end
29
- @load.merge!(@info)
27
+ end
28
+ @load.merge!(@info)
30
29
 
31
30
  else
32
31
  puts "project #{value} does not exist , will you create it(y/n)"
33
32
  gets
34
33
  if $_.chomp == 'y'
35
- file = File.new("#{project_path}/#{value}.yml","w")
34
+ file = File.new("#{project_path}/#{value}.yml", "w")
36
35
  file << "---\n"
37
36
  file << "example:\n"
38
37
  file << " ip: nil\n"
@@ -45,17 +44,13 @@ class ADD
45
44
  end
46
45
  end
47
46
 
48
-
49
- File.open("#{project_path}/#{value}.yml","w") do |file|
50
- YAML.dump(@load,file)
47
+ File.open("#{project_path}/#{value}.yml", "w") do |file|
48
+ YAML.dump(@load, file)
51
49
  file.close
52
50
  #file.write @info.to_yaml
53
51
  puts "update successfully"
54
52
  end
55
-
56
-
57
53
  end
58
-
59
54
  end
60
55
 
61
56
 
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  class Core_p
3
- attr_accessor :project , :server_alias
3
+ attr_accessor :project, :server_alias
4
4
  $public_key_path = File.expand_path("~/.ssh/id_rsa.pub")
5
5
  $config_path = File.expand_path("~/.loginx/config/config.yml")
6
6
  $project_path = File.expand_path("~/.loginx/projects/")
7
7
 
8
- def initialize(project,server_alias)
8
+ def initialize(project, server_alias)
9
9
  self.project = project
10
10
  self.server_alias = server_alias
11
11
  if !File.exist?("#{$public_key_path}")
@@ -16,14 +16,14 @@ class Core_p
16
16
 
17
17
  #when trying to send public key
18
18
  def generate_key
19
- puts "please enter return 3 times"
20
- cmd = "ssh-keygen -t rsa"
21
- `#{cmd}`
19
+ puts "please enter return 3 times"
20
+ cmd = "ssh-keygen -t rsa"
21
+ `#{cmd}`
22
22
  end
23
23
 
24
24
  def login
25
25
  if Loginx::Exist.project_exist?(self.project)
26
- config = YAML::load (File.open("#{$config_path}"))
26
+ config = YAML::load (File.open("#{$config_path}"))
27
27
  info = YAML::load(File.open("#{$project_path}/#{self.project}.yml"))
28
28
  if !info.has_key?(self.server_alias)
29
29
  puts "sorry the server alias does not exist"
@@ -34,45 +34,45 @@ class Core_p
34
34
  ip = info[self.server_alias]['ip']
35
35
  password = info[self.server_alias]['password']
36
36
 
37
- puts "do you want to send your ssh key"
38
- puts "enter return to skip or 'y' to continue to send your key"
39
- flag = STDIN.gets.chomp
40
- if flag == 'y'
41
- cmd2 = "ssh-copy-id -i #{user}@#{ip}"
42
- #exec "#{cmd2}"
43
- exp = RubyExpect::Expect.spawn("#{cmd2}")
44
- exp.procedure do
45
- any do
46
- expect /Permission denied/ do
47
- puts "this user is not allowed"
48
- exit 0
49
- end
50
-
51
- expect /continue connecting/ do
52
- send "yes"
53
- end
37
+ puts "do you want to send your ssh key"
38
+ puts "enter return to skip or 'y' to continue to send your key"
39
+ flag = STDIN.gets.chomp
40
+ if flag == 'y'
41
+ cmd2 = "ssh-copy-id -i #{user}@#{ip}"
42
+ #exec "#{cmd2}"
43
+ exp = RubyExpect::Expect.spawn("#{cmd2}")
44
+ exp.procedure do
45
+ any do
46
+ expect /Permission denied/ do
47
+ puts "this user is not allowed"
48
+ exit 0
49
+ end
54
50
 
55
- expect /Connection refused/ do
56
- puts "please check your port setting or password"
57
- exit 0
58
- end
51
+ expect /continue connecting/ do
52
+ send "yes\r"
53
+ end
59
54
 
60
- expect /already exist/ do
61
- puts "you already added keys before"
62
- exit 0
63
- end
55
+ expect /Connection refused/ do
56
+ puts "please check your port setting or password"
57
+ exit 0
58
+ end
64
59
 
65
- expect /assword/ do
66
- send "#{password}"
67
- sleep 3
68
- puts "now you can try again, or use |ssh #{user}@#{ip}| if failed please check your password"
69
- exit 0
70
- end
60
+ expect /already exist/ do
61
+ puts "you already added keys before"
62
+ exit 0
63
+ end
71
64
 
72
- run
65
+ expect /assword/ do
66
+ send "#{password}\r"
67
+ sleep 3
68
+ puts "now you can try again, or use |ssh #{user}@#{ip}| if failed please check your password"
69
+ exit 0
73
70
  end
71
+
72
+ run
74
73
  end
75
74
  end
75
+ end
76
76
 
77
77
  cmd = "ssh -p #{port} #{user}@#{ip}"
78
78
  exec "#{cmd}"
@@ -81,6 +81,4 @@ class Core_p
81
81
  exit 1
82
82
  end
83
83
  end
84
-
85
-
86
84
  end
@@ -9,27 +9,27 @@ class Delete_p
9
9
  def del_record(value)
10
10
  project_path = File.expand_path("~/.loginx/projects/")
11
11
  if Loginx::Exist.project_exist?(value)
12
- @load = YAML::load(File.open("#{project_path}/#{value}.yml"))
13
- if !@load.has_key?(self.server_alias)
14
- puts "sorry the server alias does not exist"
15
- exit 1
16
- end
17
- puts "Are you sure to delete it(y/n)"
18
- gets
19
- if $_.chomp =='y'
20
- @load.delete(self.server_alias)
21
- else
22
- puts "nothing changed"
23
- exit 1
24
- end
12
+ @load = YAML::load(File.open("#{project_path}/#{value}.yml"))
13
+ if !@load.has_key?(self.server_alias)
14
+ puts "sorry the server alias does not exist"
15
+ exit 1
16
+ end
17
+ puts "Are you sure to delete it(y/n)"
18
+ gets
19
+ if $_.chomp =='y'
20
+ @load.delete(self.server_alias)
21
+ else
22
+ puts "nothing changed"
23
+ exit 1
24
+ end
25
25
  else
26
26
  puts "project #{value} does not exist!"
27
27
  exit 1
28
28
  end
29
29
 
30
30
 
31
- File.open("#{project_path}/#{value}.yml","w") do |file|
32
- YAML.dump(@load,file)
31
+ File.open("#{project_path}/#{value}.yml", "w") do |file|
32
+ YAML.dump(@load, file)
33
33
  file.close
34
34
  #file.write @info.to_yaml
35
35
  puts "update successfully"
@@ -37,22 +37,21 @@ class Delete_p
37
37
  end
38
38
 
39
39
 
40
-
41
40
  def del_file(value)
42
41
  project_path = File.expand_path("~/.loginx/projects/")
43
42
 
44
43
  if Loginx::Exist.project_exist?(value)
45
44
 
46
- puts "Are you sure to delete it(y/n)"
47
- gets
48
- if $_.chomp =='y'
45
+ puts "Are you sure to delete it(y/n)"
46
+ gets
47
+ if $_.chomp =='y'
49
48
 
50
- File.delete("#{project_path}/#{value}.yml")
51
- puts "update successfully"
52
- else
53
- puts "nothing changed"
54
- exit 1
55
- end
49
+ File.delete("#{project_path}/#{value}.yml")
50
+ puts "update successfully"
51
+ else
52
+ puts "nothing changed"
53
+ exit 1
54
+ end
56
55
  else
57
56
  puts "project #{value} does not exist!"
58
57
  exit 1
@@ -60,10 +59,3 @@ class Delete_p
60
59
  end
61
60
 
62
61
  end
63
-
64
-
65
-
66
-
67
-
68
-
69
-
@@ -4,7 +4,6 @@ require 'find'
4
4
  class List_p
5
5
  attr_accessor :project
6
6
 
7
-
8
7
  def initialize(value)
9
8
  self.project = value
10
9
  end
@@ -2,7 +2,6 @@
2
2
  require "loginx/version"
3
3
 
4
4
  module Loginx
5
- # Your code goes here...
6
5
  class Exist
7
6
 
8
7
  def self.project_exist?(value)
@@ -10,23 +9,20 @@ module Loginx
10
9
  @flag = 0
11
10
 
12
11
  if File.exist?("#{project_path}")
13
- Find.find("#{project_path}") do |filename|
14
- if File.basename(filename,'.yml') == value
15
- @flag = 1
16
- return true
12
+ Find.find("#{project_path}") do |filename|
13
+ if File.basename(filename, '.yml') == value
14
+ @flag = 1
15
+ return true
16
+ end
17
17
  end
18
- end
19
18
 
20
- if @flag == 0
21
- return false
22
- end
19
+ if @flag == 0
20
+ return false
21
+ end
23
22
 
24
23
  else
25
24
  puts "initialize successfully,please try again"
26
25
  end
27
-
28
26
  end
29
-
30
-
31
27
  end
32
28
  end
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module Loginx
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
  end
@@ -11,17 +11,15 @@ class Setport
11
11
  def update
12
12
  config_path = File.expand_path("~/.loginx/config/config.yml")
13
13
  if File.exist?("#{config_path}")
14
- config = YAML::load (File.open("#{config_path}"))
15
- config['config']['port'] = self.port
16
- File.open("#{config_path}","w") do |file|
17
- file.write config.to_yaml
18
- file.close
19
- puts "update successfully,now default user is #{self.port}"
20
- end
14
+ config = YAML::load (File.open("#{config_path}"))
15
+ config['config']['port'] = self.port
16
+ File.open("#{config_path}","w") do |file|
17
+ file.write config.to_yaml
18
+ file.close
19
+ puts "update successfully,now default user is #{self.port}"
20
+ end
21
21
  else
22
22
  puts "initialize successfully please try again"
23
23
  end
24
-
25
24
  end
26
-
27
25
  end
@@ -11,17 +11,15 @@ class Setuser
11
11
  def update
12
12
  config_path = File.expand_path("~/.loginx/config/config.yml")
13
13
  if File.exist?("#{config_path}")
14
- config = YAML::load (File.open("#{config_path}"))
15
- config['config']['user'] = self.user
16
- File.open("#{config_path}","w") do |file|
17
- file.write config.to_yaml
18
- file.close
19
- puts "update successfully,now default user is #{self.user}"
20
- end
14
+ config = YAML::load (File.open("#{config_path}"))
15
+ config['config']['user'] = self.user
16
+ File.open("#{config_path}", "w") do |file|
17
+ file.write config.to_yaml
18
+ file.close
19
+ puts "update successfully,now default user is #{self.user}"
20
+ end
21
21
  else
22
22
  puts "initialize successfully please try again"
23
23
  end
24
-
25
24
  end
26
-
27
25
  end
@@ -15,15 +15,15 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
 
18
-
19
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
19
  spec.bindir = "bin"
21
20
  spec.executables = ["loginx"]
22
21
  spec.require_paths = ["lib"]
23
22
 
23
+ spec.add_dependency 'methadone', '>= 1.9.3'
24
+ spec.add_dependency 'ruby_expect'
25
+
24
26
  spec.add_development_dependency "bundler", ">= 1.12"
25
27
  spec.add_development_dependency "rake", ">= 10.0"
26
- spec.add_dependency('methadone', '>= 1.9.3')
27
- spec.add_dependency('ruby_expect')
28
28
 
29
29
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - terryshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: methadone
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
20
- type: :development
19
+ version: 1.9.3
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: 1.9.3
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: ruby_expect
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
33
+ version: '0'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: methadone
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.3
48
- type: :runtime
47
+ version: '1.12'
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.9.3
54
+ version: '1.12'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ruby_expect
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
61
+ version: '10.0'
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '10.0'
69
69
  description: quick login using ssh key and manage your server infomation
70
70
  email:
71
71
  - terryshi96@yahoo.com
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.6.6
116
+ rubygems_version: 2.6.14
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: quick login