teuton 2.1.8 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -8
- data/bin/check_teuton +43 -0
- data/docs/changelog/contributions.md +32 -0
- data/docs/changelog/v2.1.md +22 -0
- data/docs/changelog/v2.2.md +29 -0
- data/docs/commands/README.md +105 -7
- data/docs/commands/example_check.md +54 -0
- data/docs/commands/example_run.md +112 -0
- data/docs/dsl/README.md +11 -9
- data/docs/dsl/definition/expect.md +25 -21
- data/docs/dsl/definition/group.md +5 -1
- data/docs/dsl/definition/result.md +45 -34
- data/docs/dsl/definition/run_local.md +34 -0
- data/docs/dsl/definition/run_remote.md +119 -0
- data/docs/dsl/definition/target.md +6 -0
- data/docs/dsl/execution/export.md +27 -19
- data/docs/dsl/execution/play.md +4 -0
- data/docs/dsl/execution/send.md +21 -2
- data/docs/dsl/execution/show.md +13 -8
- data/docs/dsl/setting/get.md +24 -8
- data/docs/dsl/setting/set.md +8 -3
- data/docs/install/README.md +19 -26
- data/docs/install/modes_of_use.md +27 -26
- data/docs/install/scripts.md +53 -36
- data/docs/install/vagrant_docker.md +56 -0
- data/docs/learn/README.md +13 -6
- data/docs/learn/example-01-target.md +78 -61
- data/docs/learn/example-02-config.md +152 -0
- data/docs/learn/example-03-remote-hosts.md +31 -25
- data/docs/learn/example-04-use.md +23 -17
- data/docs/learn/example-05-debug.md +24 -17
- data/docs/learn/example-06-log.md +70 -0
- data/lib/teuton/application.rb +7 -4
- data/lib/teuton/case_manager/case/case.rb +4 -1
- data/lib/teuton/case_manager/case/dsl/expect.rb +3 -1
- data/lib/teuton/case_manager/case/dsl/goto.rb +12 -7
- data/lib/teuton/case_manager/case/dsl/macro.rb +38 -0
- data/lib/teuton/case_manager/case/dsl/main.rb +1 -2
- data/lib/teuton/case_manager/case/dsl/target.rb +1 -1
- data/lib/teuton/case_manager/case/runner.rb +7 -7
- data/lib/teuton/case_manager/case_manager.rb +1 -20
- data/lib/teuton/case_manager/check_cases.rb +12 -2
- data/lib/teuton/case_manager/dsl.rb +4 -6
- data/lib/teuton/case_manager/export_manager.rb +29 -3
- data/lib/teuton/case_manager/report.rb +29 -8
- data/lib/teuton/case_manager/show.rb +8 -4
- data/lib/teuton/cli.rb +1 -0
- data/lib/teuton/cli/play.rb +1 -0
- data/lib/teuton/cli/version.rb +1 -4
- data/lib/teuton/files/config.yaml +0 -1
- data/lib/teuton/files/start.rb +1 -1
- data/lib/teuton/files/template/case.html +135 -0
- data/lib/teuton/files/template/resume.html +115 -0
- data/lib/teuton/project/laboratory/builtin.rb +2 -1
- data/lib/teuton/project/laboratory/dsl.rb +13 -15
- data/lib/teuton/project/laboratory/laboratory.rb +5 -1
- data/lib/teuton/project/laboratory/show.rb +21 -13
- data/lib/teuton/project/name_file_finder.rb +6 -1
- data/lib/teuton/project/project.rb +7 -3
- data/lib/teuton/project/readme/dsl.rb +3 -1
- data/lib/teuton/project/readme/readme.rb +37 -26
- data/lib/teuton/project/skeleton.rb +20 -4
- data/lib/teuton/report/close.rb +15 -11
- data/lib/teuton/report/formatter/formatter_factory.rb +10 -6
- data/lib/teuton/report/formatter/html_formatter.rb +16 -79
- data/lib/teuton/report/formatter/resume_html_formatter.rb +39 -0
- data/lib/teuton/report/formatter/resume_yaml_formatter.rb +7 -1
- data/lib/teuton/report/report.rb +5 -4
- data/lib/teuton/report/show.rb +55 -26
- metadata +26 -39
- data/docs/changelog/todo.md +0 -46
- data/docs/commands/create_skeleton.md +0 -31
- data/docs/commands/help.md +0 -13
- data/docs/commands/revise_test.md +0 -46
- data/docs/commands/run_test_unit.md +0 -78
- data/docs/commands/show_version.md +0 -9
- data/docs/developers/01-telnet.md +0 -121
- data/docs/developers/02-ssh.md +0 -93
- data/docs/developers/03-encoding.md +0 -153
- data/docs/developers/comparative.md +0 -17
- data/docs/dsl/_Sidebar.md +0 -30
- data/docs/dsl/definition/goto.md +0 -112
- data/docs/dsl/definition/run.md +0 -23
- data/docs/install/tested_os.md +0 -25
- data/docs/install/vagrant.md +0 -9
- data/docs/learn/example-02-configfile.md +0 -174
- data/docs/learn/quick-demo.md +0 -170
- data/lib/teuton/case_manager/case/dsl/check.rb +0 -24
- data/lib/teuton/case_manager/case/dsl/missing.rb +0 -12
- data/lib/teuton/files/gitignore +0 -2
data/docs/changelog/todo.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# TO-DO list
|
|
3
|
-
|
|
4
|
-
List of things to do, classified into 3 sections:
|
|
5
|
-
* (A) I know read and write.
|
|
6
|
-
* (B) I work as IT teacher
|
|
7
|
-
* (C) I want to program ruby language
|
|
8
|
-
|
|
9
|
-
> I write this list without any criteria.
|
|
10
|
-
> Only an unordered list of interesting/usefull things to be done.
|
|
11
|
-
|
|
12
|
-
## Section A
|
|
13
|
-
|
|
14
|
-
Documentation
|
|
15
|
-
|
|
16
|
-
* Revise Spanish docs (ES - Mejorar la documentación en español)
|
|
17
|
-
* Revise English documents. Update english version with changes done into spanish version.
|
|
18
|
-
* Make videos showing how to use this tool
|
|
19
|
-
* Video about download and install this tool
|
|
20
|
-
* Test installation scripts
|
|
21
|
-
* Vídeo with Windows installation.
|
|
22
|
-
* Video using examples 01 to 05...
|
|
23
|
-
* Write a special documentation for novice
|
|
24
|
-
|
|
25
|
-
## Section B
|
|
26
|
-
|
|
27
|
-
* Create your own (simple or complex) educational test.
|
|
28
|
-
* Upload your own educational test to this repository.
|
|
29
|
-
|
|
30
|
-
## Section C
|
|
31
|
-
|
|
32
|
-
* `goto :host1, :puppet => "Puppet instructions"`
|
|
33
|
-
* `goto :host1, :chef => "Chef instructions"`
|
|
34
|
-
* `result.test("...")`
|
|
35
|
-
* `send :email_to => :members_emails`
|
|
36
|
-
|
|
37
|
-
Gamification
|
|
38
|
-
* When students demand help they could recibe some advises.
|
|
39
|
-
* Define a loop of executions of our activity. For example:
|
|
40
|
-
every 5 minutes, run the activity, and repeat this 10 times.
|
|
41
|
-
`start :times=>10, :duration=>5 do`
|
|
42
|
-
* More ideas: bonus, lives, etc.
|
|
43
|
-
|
|
44
|
-
Create 2 evaluation modes:
|
|
45
|
-
1. Evaluate targets (current mode): `start :score=>:targets do ...`
|
|
46
|
-
1. Evaluate task: `start :score=>:tasks do ...`
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Create skeleton
|
|
3
|
-
|
|
4
|
-
Create skeleton for a new "foo" project: `teuton create foo`
|
|
5
|
-
|
|
6
|
-
## Execution
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
$ teuton create foo
|
|
10
|
-
|
|
11
|
-
[INFO] Create project <foo>
|
|
12
|
-
* Create dir => foo
|
|
13
|
-
* Create dir => foo/assets
|
|
14
|
-
* Create file => foo/start.rb
|
|
15
|
-
* Create file => foo/config.yaml
|
|
16
|
-
* Create file => foo/.gitignore
|
|
17
|
-
* Create file => foo/README.md
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Skeleton
|
|
21
|
-
|
|
22
|
-
This command will create:
|
|
23
|
-
|
|
24
|
-
| File/Directory | Description |
|
|
25
|
-
| --------------- | -------------- |
|
|
26
|
-
| foo | Base directory |
|
|
27
|
-
| foo/assets | Base directory for other resources (images and text files) |
|
|
28
|
-
| foo/start.rb | Main Script |
|
|
29
|
-
| foo/config.yaml | YAML configuration file |
|
|
30
|
-
| foo/.gitignore | Prevent uploading YAML files to git repository |
|
|
31
|
-
| foo/README.md | Statement of our practice |
|
data/docs/commands/help.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Running `teuton` without params will show you usage information:
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
$ teuton
|
|
5
|
-
Commands:
|
|
6
|
-
teuton [play] [--export=FORMAT] DIRECTORY # Run challenge from directory
|
|
7
|
-
teuton create DIRECTORY # Create skeleton for a new project
|
|
8
|
-
teuton download # Download Teuton challenges from git repo
|
|
9
|
-
teuton help [COMMAND] # Describe available commands or one specific command
|
|
10
|
-
teuton test DIRECTORY # Check challenge contents
|
|
11
|
-
teuton update # Update TEUTON from git repo
|
|
12
|
-
teuton version # Show the program version
|
|
13
|
-
```
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Revise Test Unit
|
|
3
|
-
|
|
4
|
-
## Example 01
|
|
5
|
-
|
|
6
|
-
Revising Test Unit called `learn\learn-01-target`:
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
$ teuton test learn/learn-01-target
|
|
10
|
-
[INFO] ScriptPath => /home/david/proy/repos/teuton.d/challenges/learn/learn-01-target/start.rb
|
|
11
|
-
[INFO] ConfigPath => /home/david/proy/repos/teuton.d/challenges/learn/learn-01-target/config.yaml
|
|
12
|
-
[INFO] TestName => learn-01-target
|
|
13
|
-
|
|
14
|
-
+------------------------+
|
|
15
|
-
| GROUP: learn-01-target |
|
|
16
|
-
+------------------------+
|
|
17
|
-
(001) target Create user <david>
|
|
18
|
-
weight 1.0
|
|
19
|
-
goto localhost and {:exec=>"id david"}
|
|
20
|
-
expect david (String)
|
|
21
|
-
|
|
22
|
-
+--------------+-------+
|
|
23
|
-
| DSL Stats | Count |
|
|
24
|
-
+--------------+-------+
|
|
25
|
-
| Groups | 1 |
|
|
26
|
-
| Targets | 1 |
|
|
27
|
-
| Goto | 1 |
|
|
28
|
-
| * localhost | 1 |
|
|
29
|
-
| Uniques | 0 |
|
|
30
|
-
| Logs | 0 |
|
|
31
|
-
| | |
|
|
32
|
-
| Gets | 0 |
|
|
33
|
-
| Sets | 0 |
|
|
34
|
-
+--------------+-------+
|
|
35
|
-
+----------------------+
|
|
36
|
-
| Revising CONFIG file |
|
|
37
|
-
+----------------------+
|
|
38
|
-
[WARN] File /home/david/proy/repos/teuton.d/challenges/learn/learn-01-target/config.yaml not found!
|
|
39
|
-
[INFO] Recomended content:
|
|
40
|
-
---
|
|
41
|
-
:global:
|
|
42
|
-
:cases:
|
|
43
|
-
- :tt_members: VALUE
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Notice that this Test Unit hasn't config file, and Teuton suggests us content for our config.file. But it isn't necessary for this example.
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Run Test Unit
|
|
3
|
-
|
|
4
|
-
We use `teuton play` command to run a Test Unit (or challenge).
|
|
5
|
-
|
|
6
|
-
This command executes challenge (Test Unit) from specified directory. By default, show progress on the screen.
|
|
7
|
-
|
|
8
|
-
## Help
|
|
9
|
-
|
|
10
|
-
Run `teuton help play` to see help.
|
|
11
|
-
|
|
12
|
-
Usage:
|
|
13
|
-
* teuton [play] [OPTIONS] DIRECTORY
|
|
14
|
-
|
|
15
|
-
Options:
|
|
16
|
-
* [--export=EXPORT], select output format.
|
|
17
|
-
* [--cname=CNAME], select other config file name.
|
|
18
|
-
* [--cpath=CPATH], select absolute path to config file.
|
|
19
|
-
* [--case=CASE], select cases to be tested.
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
| ID | Command | Descriptiont |
|
|
24
|
-
| -- | -------------------- | ------------ |
|
|
25
|
-
| 01 | teuton foo | Run foo/start.rb, with config file foo/config.yaml |
|
|
26
|
-
| 02 | teuton play foo | Run foo/start.rb, with config file foo/config.yaml |
|
|
27
|
-
| 03 | ruby teuton foo | Same as 01 on Windows OS |
|
|
28
|
-
| 04 | ruby teuton play foo | Same as 02 on WIndows OS |
|
|
29
|
-
| 05 | teuton . | Run ./start.rb with ./config.yaml file |
|
|
30
|
-
| 06 | teuton play --export=json foo | Run foo/start.rb and force json format during exporting. Others output formats availables are: txt, colored_text, json, yaml |
|
|
31
|
-
| 07 | teuton play --cname=class foo | Run foo/start.rb with foo/class.yaml config file |
|
|
32
|
-
| 08 | teuton foo/demo42.rb | Run foo/demo42.rb with foo/demo42.yaml config file |
|
|
33
|
-
| 08 | teuton play --cpath=current/class.yaml foo | Run foo/start.rb with current/class.yaml config file |
|
|
34
|
-
| 10 | teuton play --case=6,16 foo | Run foo/start.rb with foo/config.yaml config file but only for case id 6 and 16 |
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Example
|
|
39
|
-
|
|
40
|
-
Running example 01:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
$ teuton learn/learn-01-target
|
|
44
|
-
[INFO] ScriptPath => /home/david/proy/repos/teuton.d/challenges/learn/learn-01-target/start.rb
|
|
45
|
-
[INFO] ConfigPath => /home/david/proy/repos/teuton.d/challenges/learn/learn-01-target/config.yaml
|
|
46
|
-
[INFO] TestName => learn-01-target
|
|
47
|
-
|
|
48
|
-
==================================
|
|
49
|
-
Executing [teuton] (version 2.1.0)
|
|
50
|
-
[INFO] Running in parallel (2019-10-04 23:44:19 +0100)
|
|
51
|
-
Starting case <anonymous>
|
|
52
|
-
* Processing <learn-01-target> .
|
|
53
|
-
|
|
54
|
-
[INFO] Duration = 0.006568696 (2019-10-04 23:44:19 +0100)
|
|
55
|
-
==================================
|
|
56
|
-
|
|
57
|
-
INITIAL CONFIGURATIONS
|
|
58
|
-
+---------------+-------------------------------------------------------+
|
|
59
|
-
| tt_title | Executing [teuton] (version 2.1.0) |
|
|
60
|
-
| tt_scriptname | ...teuton.d/challenges/learn/learn-01-target/start.rb |
|
|
61
|
-
| tt_configfile | ...ton.d/challenges/learn/learn-01-target/config.yaml |
|
|
62
|
-
| tt_testname | learn-01-target |
|
|
63
|
-
| tt_sequence | false |
|
|
64
|
-
+---------------+-------------------------------------------------------+
|
|
65
|
-
|
|
66
|
-
CASE RESULTS
|
|
67
|
-
+---------+-------+-------+-----------+
|
|
68
|
-
| CASE ID | GRADE | STATE | MEMBERS |
|
|
69
|
-
| case_01 | 100.0 | | anonymous |
|
|
70
|
-
+---------+-------+-------+-----------+
|
|
71
|
-
|
|
72
|
-
FINAL VALUES
|
|
73
|
-
+-------------+---------------------------+
|
|
74
|
-
| start_time | 2019-10-04 23:44:19 +0100 |
|
|
75
|
-
| finish_time | 2019-10-04 23:44:19 +0100 |
|
|
76
|
-
| duration | 0.006568696 |
|
|
77
|
-
+-------------+---------------------------+
|
|
78
|
-
```
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# 01 - Conexión Telnet
|
|
3
|
-
|
|
4
|
-
> ¡Vale, lo sé! No debería estar usando Telnet ni Windows 2012.
|
|
5
|
-
> Pero ahora mismo es un reto personal y quiero descubrir qué está pasando.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Herramientas que uso
|
|
10
|
-
|
|
11
|
-
He creado el siguiente [programa ruby](../../tests/manual/telnet.rb) para abrir
|
|
12
|
-
una conexión telnet a una máquina remota, ejecutar un comando y mostrar
|
|
13
|
-
el resutado en pantalla.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
# Gema net/Telnet
|
|
18
|
-
|
|
19
|
-
Estoy usando la gema `net/telnet`, la cual en su [documentación](https://www.rubydoc.info/gems/net-telnet/0.2.0)
|
|
20
|
-
pone lo siguiente:
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
# Usage
|
|
24
|
-
# Log in and send a command, echoing all output to stdout
|
|
25
|
-
|
|
26
|
-
localhost = Net::Telnet::new("Host" => "localhost",
|
|
27
|
-
"Timeout" => 10,
|
|
28
|
-
"Prompt" => /[$%#>] \z/n)
|
|
29
|
-
localhost.login("username", "password") { |c| print c }
|
|
30
|
-
localhost.cmd("command") { |c| print c }
|
|
31
|
-
localhost.close
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
> Repositorio GitHub de la gema: https://github.com/ruby/net-telnet/
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
# Comprobaciones
|
|
39
|
-
|
|
40
|
-
## MV GNU/Linux Debian 9 con servidor telnet
|
|
41
|
-
* Manualmente -> OK
|
|
42
|
-
* Usando el programa -> OK
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
Testing : {:ip=>"192.168.1.106", :username=>"root", :password=>"profesor", :cmd=>"whoami"}
|
|
46
|
-
Output : ["whoami", "root", "root@vargas42d:~# "]
|
|
47
|
-
|
|
48
|
-
Testing : {:ip=>"192.168.1.106", :username=>"profesor", :password=>"profesor", :cmd=>"whoami"}
|
|
49
|
-
Output : ["whoami", "profesor", "profesor@vargas42d:~$ "]
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## MV Windows 2008 server con servidor Telnet
|
|
53
|
-
* Manualmente -> OK
|
|
54
|
-
* Usando el programa -> OK
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
Testing : {:ip=>"192.168.1.115", :username=>"Administrador", :password=>"profesorFP2018", :cmd=>"whoami"}
|
|
58
|
-
Output : ["whoami", "vargas42s08\\administrador", "", "C:\\Users\\Administrador>"]
|
|
59
|
-
|
|
60
|
-
Testing : {:ip=>"192.168.1.115", :username=>"profesor", :password=>"sayonaraBABY2018", :cmd=>"whoami"}
|
|
61
|
-
Output : ["whoami", "vargas42s08\\profesor", "", "C:\\Users\\profesor>"]
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## MV Windows 2012 server con servidor Telnet
|
|
65
|
-
* Manualmente -> OK
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
david@camaleon:~/proy/tools/sysadmin-game> telnet 192.168.1.114
|
|
69
|
-
Trying 192.168.1.114...
|
|
70
|
-
Connected to 192.168.1.114.
|
|
71
|
-
Escape character is '^]'.
|
|
72
|
-
Welcome to Microsoft Telnet Service
|
|
73
|
-
|
|
74
|
-
login: administrador
|
|
75
|
-
password:
|
|
76
|
-
|
|
77
|
-
*===============================================================
|
|
78
|
-
Microsoft Telnet Server.
|
|
79
|
-
*===============================================================
|
|
80
|
-
C:\Users\Administrador>whoami
|
|
81
|
-
vargas42s12\administrador
|
|
82
|
-
|
|
83
|
-
C:\Users\Administrador>
|
|
84
|
-
C:\Users\Administrador>exitConnection closed by foreign host.
|
|
85
|
-
david@camaleon:~/proy/tools/sysadmin-game> telnet 192.168.1.114
|
|
86
|
-
Trying 192.168.1.114...
|
|
87
|
-
Connected to 192.168.1.114.
|
|
88
|
-
Escape character is '^]'.
|
|
89
|
-
Welcome to Microsoft Telnet Service
|
|
90
|
-
|
|
91
|
-
login: profesor
|
|
92
|
-
password:
|
|
93
|
-
|
|
94
|
-
*===============================================================
|
|
95
|
-
Microsoft Telnet Server.
|
|
96
|
-
*===============================================================
|
|
97
|
-
C:\>whoami
|
|
98
|
-
vargas42s12\profesor
|
|
99
|
-
|
|
100
|
-
C:\>exiConnection closed by foreign host.
|
|
101
|
-
```
|
|
102
|
-
* Usando el programa -> OK
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
david@camaleon:~/proy/tools/sysadmin-game> ./tests/manual/telnet.rb
|
|
106
|
-
|
|
107
|
-
Testing : {:ip=>"192.168.1.114", :username=>"Administrador", :password=>"profesorFP2018", :cmd=>"whoami"}
|
|
108
|
-
Output : ["whoami", "vargas42s12\\administrador", "", "C:\\Users\\Administrador>"]
|
|
109
|
-
|
|
110
|
-
Testing : {:ip=>"192.168.1.114", :username=>"profesor", :password=>"sayonaraBABY2018", :cmd=>"whoami"}
|
|
111
|
-
Output : ["whoami", "vargas42s12\\profesor", "", "C:\\Users\\profesor>"]
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
# Problema
|
|
117
|
-
|
|
118
|
-
La aplicación falla cuando lo intento con Windows 2012 server.
|
|
119
|
-
|
|
120
|
-
Creo que la estoy usando correctamente, pero hay algo que funciona diferente
|
|
121
|
-
en Windows 2012 y no consigo identificar el qué.
|
data/docs/developers/02-ssh.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# 02 - Conexión SSH a PowerShell
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Herramientas que uso
|
|
7
|
-
|
|
8
|
-
He creado el programa de ruby [ssh.rb](../../tests/manual/ssh.rb) para abrir
|
|
9
|
-
una conexión SSH a una máquina remota, ejecutar un comando y mostrar
|
|
10
|
-
el resutado en pantalla.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# Gema net/ssh
|
|
15
|
-
|
|
16
|
-
Estoy usando la gema `net/ssh`, la cual en su [documentación](hhttp://net-ssh.github.io/net-ssh/)
|
|
17
|
-
pone lo siguiente:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
require 'net/ssh'
|
|
21
|
-
|
|
22
|
-
Net::SSH.start('host', 'user', password: "password") do |ssh|
|
|
23
|
-
# capture all stderr and stdout output from a remote process
|
|
24
|
-
output = ssh.exec!("hostname")
|
|
25
|
-
puts output
|
|
26
|
-
end
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
> Repositorio GitHub de la gema: https://github.com/net-ssh/net-ssh
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
# Comprobaciones
|
|
34
|
-
|
|
35
|
-
## Debian 9 con servidor SSH
|
|
36
|
-
|
|
37
|
-
Todos los comandos que se ejecutan vía SSH por esta herramienta funcionan correctamente.
|
|
38
|
-
|
|
39
|
-
## MV Windows 2012 server con servidor SSH
|
|
40
|
-
|
|
41
|
-
* Manualmente -> OK (usando ssh con sshpass)
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
david@camaleon:~/proy/tools/sysadmin-game> sshpass -p profesorFP2018 ssh administrador@192.168.1.114 'get-windowsfeature -name rds-rd-server'
|
|
45
|
-
|
|
46
|
-
Display Name Name
|
|
47
|
-
------------ ----
|
|
48
|
-
[ ] Host de sesi�n de Escritorio remoto RDS-RD-Server
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
* Manualmente -> OK (usando ssh)
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
david@camaleon:~/proy/tools/sysadmin-game> ssh administrador@192.168.1.114 'get-windowsfeature -name rds-rd-server'
|
|
56
|
-
administrador@192.168.1.114's password:
|
|
57
|
-
|
|
58
|
-
Display Name Name
|
|
59
|
-
------------ ----
|
|
60
|
-
[ ] Host de sesi�n de Escritorio remoto RDS-RD-Server
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
* Usando el programa -> OK (Comando whoami)
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
david@camaleon:~/proy/tools/sysadmin-game> ./tests/manual/ssh.rb
|
|
67
|
-
|
|
68
|
-
Testing : {:ip=>"192.168.1.114", :username=>"Administrador", :password=>"profesorFP2018", :cmd=>"whoami"}
|
|
69
|
-
Output : ["vargas42s12\\administrador\r"]
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
* Usando el programa -> ERROR!!!! (Comando get-windowsfeature) La salida está vacía.
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
david@camaleon:~/proy/tools/sysadmin-game> ./tests/manual/ssh.rb
|
|
77
|
-
|
|
78
|
-
Testing : {:ip=>"192.168.1.114", :username=>"Administrador", :password=>"profesorFP2018", :cmd=>"get-windowsfeature -name rds-rd-server"}
|
|
79
|
-
[ArgumentError] SSH on <Administrador@192.168.1.114> exec: get-windowsfeature -name rds-rd-server
|
|
80
|
-
Output : []
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
# Problema
|
|
87
|
-
|
|
88
|
-
La librería `net/ssh` parece que no recoge el resultado cuando se ejecuta el comando de PowerShell `get-windowsfeature -name rds-server` en Windows 2012 server.
|
|
89
|
-
|
|
90
|
-
Pero si lo hago de forma manual SI funciona.
|
|
91
|
-
|
|
92
|
-
¿Puede ser que algunos comandos de PowerShell no se comportan como lo hacen todos los comandos y generan
|
|
93
|
-
una salida que no puede capturar bien la librería?
|