sshez 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/sshez +7 -0
- data/lib/sshez.rb +132 -0
- data/lib/sshez/version.rb +3 -0
- data/sshez.gemspec +27 -0
- data/tasks/rspec.rake +3 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22f9add4fa0d691c5a71d7dd7daa3e773628208d
|
4
|
+
data.tar.gz: 294c4104b066e068315ed456c6e671e27d32e8e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c93f02bb17e20f988e4ca633730f597c9414a1f0af132fcc173045a27e77ba3c7b17f101e49ef3d6092ac837440a8832a86bf7d66c414e0d4f815714872c536
|
7
|
+
data.tar.gz: d8ae9b319b8a78c42593369f5e343e18c4b90d55833706a443da150feebea226b8f8a35be3e92568b828ba64504fb4b99870481028e310fbdb6ff8acab28f1a0
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/rdoc/
|
21
|
+
|
22
|
+
## Environment normalisation:
|
23
|
+
/.bundle/
|
24
|
+
/vendor/bundle
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Immortal Friday
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Immortal Friday
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Sshez
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sshez`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sshez'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sshez
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
try sshez -h
|
26
|
+
|
27
|
+
Usage: sshez user@ip [options]
|
28
|
+
|
29
|
+
Specific options:
|
30
|
+
-p, --port PORT Specify a port
|
31
|
+
-i, --identity_file [key] Add identity
|
32
|
+
|
33
|
+
Common options:
|
34
|
+
-h, --help Show this message
|
35
|
+
--version
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
40
|
+
|
41
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Gomaak/sshez. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
46
|
+
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
51
|
+
|
52
|
+
## Output
|
53
|
+
sshez where you don't have to remember your ips or deal with ssh config
|
54
|
+
|
55
|
+
Show version
|
56
|
+
|
57
|
+
|
58
|
+
## Missing
|
59
|
+
|
60
|
+
* All the other options in [ssh documentation](http://linux.die.net/man/5/ssh_config)
|
61
|
+
* Add -r option to remove aliases
|
62
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sshez"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/sshez
ADDED
data/lib/sshez.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
require "sshez/version"
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Sshez
|
6
|
+
# Your code goes here...
|
7
|
+
|
8
|
+
|
9
|
+
class Params
|
10
|
+
|
11
|
+
#
|
12
|
+
# Return a structure describing the options.
|
13
|
+
#
|
14
|
+
def self.parse(args)
|
15
|
+
# The options specified on the command line will be collected in *options*.
|
16
|
+
# We set default values here.
|
17
|
+
options = OpenStruct.new
|
18
|
+
|
19
|
+
opt_parser = OptionParser.new do |opts|
|
20
|
+
opts.banner = "Usage: sshez name user@ip [options]"
|
21
|
+
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Specific options:"
|
24
|
+
|
25
|
+
# Mandatory argument.
|
26
|
+
opts.on("-p", "--port PORT",
|
27
|
+
"Specify a port") do |port|
|
28
|
+
options.port = port
|
29
|
+
end
|
30
|
+
|
31
|
+
# Optional argument; multi-line description.
|
32
|
+
opts.on("-i", "--identity_file [key]",
|
33
|
+
"Add identity") do |key_path|
|
34
|
+
options.identity_file = key_path
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-r", "--remove", "Remove handle") do
|
38
|
+
options.remove = true
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-t", "--test", "writes nothing") do
|
42
|
+
options.test = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.separator ""
|
46
|
+
opts.separator "Common options:"
|
47
|
+
|
48
|
+
# No argument, shows at tail. This will print an options summary.
|
49
|
+
# Try it and see!
|
50
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
51
|
+
puts opts
|
52
|
+
end
|
53
|
+
|
54
|
+
# Another typical switch to print the version.
|
55
|
+
opts.on_tail("--version", "Show version") do
|
56
|
+
puts ::Version.join('.')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
opt_parser.parse!(args)
|
61
|
+
options
|
62
|
+
end # parse()
|
63
|
+
|
64
|
+
end # class Params
|
65
|
+
|
66
|
+
class ConfigFile
|
67
|
+
def self.append(name, user, host, options)
|
68
|
+
output = "Adding\n"
|
69
|
+
config_append = form(name, user, host, options)
|
70
|
+
output += "" + config_append
|
71
|
+
unless options.test
|
72
|
+
file_path = File.expand_path('~')+"/.ssh/config"
|
73
|
+
file = File.open(file_path, "a+")
|
74
|
+
file.write(config_append)
|
75
|
+
file.close
|
76
|
+
end
|
77
|
+
output += "to #{file_path}\n"
|
78
|
+
|
79
|
+
output
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.form(name, user, host, options)
|
83
|
+
retuned = %Q|Host #{name}
|
84
|
+
HostName #{host}
|
85
|
+
User #{user}
|
86
|
+
|
|
87
|
+
if options.port
|
88
|
+
retuned += %Q| Port #{options.port}
|
89
|
+
|
|
90
|
+
end
|
91
|
+
|
92
|
+
if options.identity_file
|
93
|
+
retuned += %Q| IdentityFile #{options.identity_file}
|
94
|
+
|
|
95
|
+
end
|
96
|
+
retuned
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
class Exec
|
105
|
+
|
106
|
+
def process(args)
|
107
|
+
# parse the params to get the options
|
108
|
+
if (args.length < 2 || !args[1].include?("@"))
|
109
|
+
if args[0] == "-h"
|
110
|
+
Params.parse(args)
|
111
|
+
return nil
|
112
|
+
end
|
113
|
+
output = %Q|Invalid input
|
114
|
+
Use -h for help|
|
115
|
+
return output
|
116
|
+
end
|
117
|
+
options = Params.parse(args)
|
118
|
+
|
119
|
+
|
120
|
+
if options.remove
|
121
|
+
"Not implemented :("
|
122
|
+
else
|
123
|
+
user, host = args[1].split("@")
|
124
|
+
output = ConfigFile.append(args[0], user, host, options)
|
125
|
+
output + "Done!"
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
data/sshez.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sshez/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sshez"
|
8
|
+
spec.version = Sshez::VERSION
|
9
|
+
spec.authors = ["Immortal Friday"]
|
10
|
+
spec.email = ["khaled.gomaa.90@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Easy ssh config handling}
|
13
|
+
spec.description = %q{will interface your ssh config file
|
14
|
+
Allowing you to add aliases to your server and do a lot of cool stuff}
|
15
|
+
spec.homepage = "https://github.com/GomaaK/sshez"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.executables = ["sshez"]
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
|
27
|
+
end
|
data/tasks/rspec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sshez
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Immortal Friday
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |-
|
56
|
+
will interface your ssh config file
|
57
|
+
Allowing you to add aliases to your server and do a lot of cool stuff
|
58
|
+
email:
|
59
|
+
- khaled.gomaa.90@gmail.com
|
60
|
+
executables:
|
61
|
+
- sshez
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- bin/sshez
|
77
|
+
- lib/sshez.rb
|
78
|
+
- lib/sshez/version.rb
|
79
|
+
- sshez.gemspec
|
80
|
+
- tasks/rspec.rake
|
81
|
+
homepage: https://github.com/GomaaK/sshez
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.4.5
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Easy ssh config handling
|
105
|
+
test_files: []
|