cucumber-sshd 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/Rakefile +5 -0
- data/lib/cucumber/sshd/server.rb +44 -18
- data/lib/cucumber/sshd/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56e971d95f3760c3b7fc55e9dae3e329d7b4931
|
4
|
+
data.tar.gz: f0e4c1ad873b771f9c60a2663da310cafce911d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91d36d8c6c61d9856dd8851f1736d2243371dfbb98981e108f9124a437e4857875d4df4363787de9bcad55494e88c0c2934261bb63bc3083d0baf4975dacf78
|
7
|
+
data.tar.gz: 160eb4ca89a9d7bf3c489f122c7794d7cad97d59b2a087820d85b69cdd7ac34efdcaa379f6564d2b66c73e2900b5f65c01b4abb0baa1ba6ccca2f8c2380fa059
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.2
|
6
|
+
- ruby-head
|
7
|
+
- 2.1
|
8
|
+
before_script:
|
9
|
+
- ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
|
10
|
+
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
11
|
+
- chmod 600 ~/.ssh/authorized_keys
|
12
|
+
- eval `ssh-agent -s`
|
13
|
+
- ssh-add ~/.ssh/id_rsa
|
data/Rakefile
ADDED
data/lib/cucumber/sshd/server.rb
CHANGED
@@ -5,15 +5,19 @@ module Cucumber
|
|
5
5
|
class Server
|
6
6
|
include Aruba::Api
|
7
7
|
|
8
|
-
HOST
|
9
|
-
PORT
|
10
|
-
COMMAND
|
11
|
-
COMMAND_ARGS
|
12
|
-
KEY_PATH
|
13
|
-
KEY_PUB_PATH
|
14
|
-
SSHD_CONFIG_PATH
|
15
|
-
SSH_CONFIG_PATH
|
16
|
-
|
8
|
+
HOST = 'some_host.test'
|
9
|
+
PORT = 2222
|
10
|
+
COMMAND = '/usr/sbin/sshd'
|
11
|
+
COMMAND_ARGS = '-Deq'
|
12
|
+
KEY_PATH = 'etc/ssh_host_rsa_key'
|
13
|
+
KEY_PUB_PATH = KEY_PATH.dup << '.pub'
|
14
|
+
SSHD_CONFIG_PATH = 'etc/sshd_config'
|
15
|
+
SSH_CONFIG_PATH = '.ssh/config'
|
16
|
+
SSH_KNOWN_HOSTS_PATH = '.ssh/known_host'
|
17
|
+
SFTP_SERVER_PATHS = %w[
|
18
|
+
/usr/libexec/sftp-server
|
19
|
+
/usr/lib/openssh/sftp-server
|
20
|
+
]
|
17
21
|
class << self
|
18
22
|
def start(*args)
|
19
23
|
server = new(args.shift, *args)
|
@@ -65,9 +69,9 @@ module Cucumber
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def make_env
|
68
|
-
%w[etc .ssh].map { |e|
|
72
|
+
%w[etc .ssh].map { |e| create_dir_secure e }
|
69
73
|
|
70
|
-
|
74
|
+
write_file_secure KEY_PATH, <<-eoh
|
71
75
|
-----BEGIN RSA PRIVATE KEY-----
|
72
76
|
MIIEpAIBAAKCAQEA7EVDKeM7NYCGGVJw0wWLGCoptMFSR7DobhbEx2bAQbWDLFBF
|
73
77
|
7S9bXpW/ddebFA4GBkHVriNPwu/IGjIgO3tivVcy6iguNKdYRABlSfpeAs+OdCzK
|
@@ -97,11 +101,11 @@ iDjcFK8S1e5vnlZAh9xH1WMCEsaz1WNqWm7CZOayN2LFn6Ed9seYYg==
|
|
97
101
|
-----END RSA PRIVATE KEY-----
|
98
102
|
eoh
|
99
103
|
|
100
|
-
|
104
|
+
write_file_secure KEY_PUB_PATH, <<-eoh
|
101
105
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsRUMp4zs1gIYZUnDTBYsYKim0wVJHsOhuFsTHZsBBtYMsUEXtL1telb9115sUDgYGQdWuI0/C78gaMiA7e2K9VzLqKC40p1hEAGVJ+l4Cz450LMqHIRaGYqcUxmzYyE+ImD8pR6naAVkugRyz2+STfv5wty5RWRdU5I9eVgK4eOCTBo32KP8q8Jws/i3Dzcfc/KHVaf9jiTX7edY3ZLdGBEcX1GMTHuebYWZdxmrXDKA97kbZtA29krKQv7CUogfAqIzgBalUKVzM6KWM2/0pE6EZZqchk00EgNOeKTEW9jQXKg/Wq9GsTwGWrE17Ib+9g2Zey/zGk7Qw4XrnPd3Z
|
102
106
|
eoh
|
103
107
|
|
104
|
-
|
108
|
+
write_file_secure SSHD_CONFIG_PATH, <<-eoh
|
105
109
|
Port #{port}
|
106
110
|
ListenAddress ::1
|
107
111
|
|
@@ -109,16 +113,38 @@ Protocol 2
|
|
109
113
|
HostKey #{File.expand_path base_path}/#{KEY_PATH}
|
110
114
|
PidFile /dev/null
|
111
115
|
UsePrivilegeSeparation no
|
112
|
-
Subsystem sftp
|
116
|
+
Subsystem sftp #{sftp_server_path}
|
113
117
|
ForceCommand HOME=#{File.expand_path base_path} sh -c "cd ~; [ -f .ssh/rc ] && . .ssh/rc; $SSH_ORIGINAL_COMMAND"
|
114
118
|
eoh
|
115
119
|
|
116
|
-
|
117
|
-
Host
|
118
|
-
HostName
|
119
|
-
Port
|
120
|
+
write_file_secure SSH_CONFIG_PATH, <<-eoh
|
121
|
+
Host #{host}
|
122
|
+
HostName localhost
|
123
|
+
Port #{port}
|
124
|
+
UserKnownHostsFile #{File.expand_path base_path}/#{SSH_KNOWN_HOSTS_PATH}
|
125
|
+
eoh
|
126
|
+
|
127
|
+
write_file_secure SSH_KNOWN_HOSTS_PATH, <<-eoh
|
128
|
+
[localhost]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsRUMp4zs1gIYZUnDTBYsYKim0wVJHsOhuFsTHZsBBtYMsUEXtL1telb9115sUDgYGQdWuI0/C78gaMiA7e2K9VzLqKC40p1hEAGVJ+l4Cz450LMqHIRaGYqcUxmzYyE+ImD8pR6naAVkugRyz2+STfv5wty5RWRdU5I9eVgK4eOCTBo32KP8q8Jws/i3Dzcfc/KHVaf9jiTX7edY3ZLdGBEcX1GMTHuebYWZdxmrXDKA97kbZtA29krKQv7CUogfAqIzgBalUKVzM6KWM2/0pE6EZZqchk00EgNOeKTEW9jQXKg/Wq9GsTwGWrE17Ib+9g2Zey/zGk7Qw4XrnPd3Z
|
120
129
|
eoh
|
121
130
|
end
|
131
|
+
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def write_file_secure(path, content)
|
136
|
+
write_file path, content
|
137
|
+
filesystem_permissions 0600, path
|
138
|
+
end
|
139
|
+
|
140
|
+
def create_dir_secure(path)
|
141
|
+
create_dir path
|
142
|
+
filesystem_permissions 0700, path
|
143
|
+
end
|
144
|
+
|
145
|
+
def sftp_server_path
|
146
|
+
SFTP_SERVER_PATHS.detect { |e| File.exist? e } or SFTP_SERVER_PATHS.first
|
147
|
+
end
|
122
148
|
end
|
123
149
|
end
|
124
150
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-sshd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
@@ -59,9 +59,11 @@ extensions: []
|
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
61
|
- ".gitignore"
|
62
|
+
- ".travis.yml"
|
62
63
|
- Gemfile
|
63
64
|
- LICENSE
|
64
65
|
- README.md
|
66
|
+
- Rakefile
|
65
67
|
- cucumber-sshd.gemspec
|
66
68
|
- features/sshd_tag.feature
|
67
69
|
- features/steps/output_steps.rb
|