githubautossh 0.1.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/githubautossh +85 -0
- data/githubautossh.gemspec +29 -0
- data/lib/githubautossh.rb +6 -0
- data/lib/githubautossh/version.rb +3 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 23e25c43df748c7f8360a7a35ebd1b142ea6ce85
|
4
|
+
data.tar.gz: ada3fbdb158c7a4613a0090c4ba6b16e1a0cb983
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8551ac8826cd8169c21ef3bd7838b2ec70852a76d554e7b494e09111b24dfffa7998835710bcb97370d94a1d8ff449f411a26920a3cdac1b43749e06afa197ec
|
7
|
+
data.tar.gz: 90d9670039926307eddedd19ecb6210bd52575f566628f514929dac828105d360d93aa019cb443a52879958115967d0294947814815b06d9958d3794ba863d52
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kesi Maduka
|
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,29 @@
|
|
1
|
+
# Github Auto SSH
|
2
|
+
|
3
|
+
A helper script to automatically create the proper SSH credentials
|
4
|
+
|
5
|
+
Features
|
6
|
+
- Automatically creates private/public keys
|
7
|
+
- Pushes keys to Github repository
|
8
|
+
- Adds keys to ssh config file
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install:
|
13
|
+
|
14
|
+
$ gem install githubautossh
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Just run
|
19
|
+
|
20
|
+
$ githubautossh
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[k3zi]/githubautossh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
25
|
+
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/githubautossh
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'githubautossh'
|
4
|
+
require 'ssh-config'
|
5
|
+
require 'highline'
|
6
|
+
require 'net/ssh'
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
cli = HighLine.new
|
10
|
+
|
11
|
+
print "Enter the Github URL of the repository: "
|
12
|
+
STDOUT.flush
|
13
|
+
github_url = gets.chomp
|
14
|
+
|
15
|
+
uri = URI.parse(github_url)
|
16
|
+
splitPaths = uri.path.split('/')
|
17
|
+
|
18
|
+
username = splitPaths[1]
|
19
|
+
repo = splitPaths[2]
|
20
|
+
|
21
|
+
print "Enter the username to access the above repo: "
|
22
|
+
STDOUT.flush
|
23
|
+
loginUsername = gets.chomp
|
24
|
+
|
25
|
+
loginPassword = cli.ask("Enter the password to access the above repo: ") { |q| q.echo = false }
|
26
|
+
|
27
|
+
Github.configure do |c|
|
28
|
+
c.basic_auth = loginUsername + ":" + loginPassword
|
29
|
+
c.user = username
|
30
|
+
c.repo = repo
|
31
|
+
end
|
32
|
+
|
33
|
+
key = OpenSSL::PKey::RSA.generate(2048)
|
34
|
+
type = key.ssh_type
|
35
|
+
data = [key.to_blob].pack('m0')
|
36
|
+
|
37
|
+
public_key_string = "#{type} #{data}"
|
38
|
+
private_key_string = key.to_pem
|
39
|
+
|
40
|
+
def push_key(username, repo, pubKey, privKey, otp)
|
41
|
+
begin
|
42
|
+
Github.configure do |c|
|
43
|
+
c.connection_options = {headers: {"X-GitHub-OTP" => otp}}
|
44
|
+
end
|
45
|
+
|
46
|
+
keys = Github::Client::Repos::Keys.new
|
47
|
+
randomString = [*('A'..'Z')].sample(8).join
|
48
|
+
name = ["github", username, repo, randomString].join('_')
|
49
|
+
create = keys.create username, repo,
|
50
|
+
title: name,
|
51
|
+
key: pubKey
|
52
|
+
|
53
|
+
saveDirectory = Dir.home + "/.ssh/"
|
54
|
+
|
55
|
+
f = File.open(saveDirectory + name + ".pub", "w+")
|
56
|
+
f.write pubKey
|
57
|
+
|
58
|
+
f = File.open(saveDirectory + name, "w+")
|
59
|
+
f.write privKey
|
60
|
+
|
61
|
+
File.open(saveDirectory + "config", "a")
|
62
|
+
ssh_config = ConfigFile.new
|
63
|
+
settings = [name, "HostName", "github.com"]
|
64
|
+
ssh_config.set!(*settings)
|
65
|
+
settings = [name, "IdentityFile", saveDirectory + name]
|
66
|
+
ssh_config.set!(*settings)
|
67
|
+
|
68
|
+
puts
|
69
|
+
puts "Congrats! Your public/private key pair has been generated!"
|
70
|
+
puts " Public Key: " + saveDirectory + name + ".pub"
|
71
|
+
puts " Private Key: " + saveDirectory + name
|
72
|
+
|
73
|
+
rescue Github::Error::GithubError => e
|
74
|
+
if e.message.include? "OTP"
|
75
|
+
print "Enter your two-faxtor OTP code: "
|
76
|
+
STDOUT.flush
|
77
|
+
otp = gets.chomp
|
78
|
+
push_key(username, repo, pubKey, privKey, otp)
|
79
|
+
else
|
80
|
+
puts e.message
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
push_key(username, repo, public_key_string, private_key_string, "")
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'githubautossh/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "githubautossh"
|
8
|
+
spec.version = Githubautossh::VERSION
|
9
|
+
spec.authors = ["Kesi Maduka"]
|
10
|
+
spec.email = ["me@kez.io"]
|
11
|
+
|
12
|
+
spec.summary = "A helper script to automatically create the proper SSH credentials"
|
13
|
+
spec.description = "A helper script that generates both public & private keys, uploads them to the specified Github repository (as deploy keys), and adds them to your ssh config file."
|
14
|
+
spec.homepage = "https://github.com/k3zi/githubautossh"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = ["githubautossh"]
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "github_api", "~> 0.13.1"
|
23
|
+
spec.add_dependency "net-ssh", "~> 2.9", ">= 2.9.2"
|
24
|
+
spec.add_dependency "highline", "~> 1.7", ">= 1.7.8"
|
25
|
+
spec.add_dependency "ssh-config", "~> 0.1.3"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: githubautossh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.01
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kesi Maduka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: github_api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-ssh
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.9'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.9.2
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.9'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.9.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: highline
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.7'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.7.8
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.7'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.7.8
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: ssh-config
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.1.3
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.1.3
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: bundler
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.11'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.11'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '10.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '10.0'
|
109
|
+
description: A helper script that generates both public & private keys, uploads them
|
110
|
+
to the specified Github repository (as deploy keys), and adds them to your ssh config
|
111
|
+
file.
|
112
|
+
email:
|
113
|
+
- me@kez.io
|
114
|
+
executables:
|
115
|
+
- githubautossh
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/githubautossh
|
125
|
+
- githubautossh.gemspec
|
126
|
+
- lib/githubautossh.rb
|
127
|
+
- lib/githubautossh/version.rb
|
128
|
+
homepage: https://github.com/k3zi/githubautossh
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.4.5.1
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: A helper script to automatically create the proper SSH credentials
|
152
|
+
test_files: []
|