Browse Source

Exercise 3: Add SSHD install check (assignment d)

master
Pekka Helenius 6 years ago
committed by GitHub
parent
commit
2667353ca4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 19 deletions
  1. +34
    -19
      h3.md

+ 34
- 19
h3.md View File

@ -408,9 +408,16 @@ Luodaan masterille tiedosto _srv/salt/ssh_random/init.sls_ (sudo mkdir -p /srv/s
```
{% set supersecret_ssh_port = range(23, 600) | random %}
check_sshd_install:
pkg.installed:
- pkgs:
- openssh-server # Ubuntu specific
check_sshd_config:
file.managed:
- name: /etc/ssh/sshd_config
- require:
- pkg: check_sshd_install
ssh_port:
cmd.run:
@ -443,27 +450,35 @@ Masterilla saatu output minionille "orjakone":
```
orjakone:
----------
ID: check_sshd_install
Function: pkg.installed
Result: True
Comment: All specified packages are already installed
Started: 23:47:14.653440
Duration: 429.865 ms
Changes:
----------
ID: check_sshd_config
Function: file.managed
Name: /etc/ssh/sshd_config
Result: True
Comment: File /etc/ssh/sshd_config exists with proper permissions. No changes made.
Started: 23:11:06.410285
Duration: 4.806 ms
Started: 23:47:15.085669
Duration: 1.391 ms
Changes:
----------
ID: ssh_port
Function: cmd.run
Name: sed -i -r "s/^[#P]+ort [0-9][0-9]*/Port 240/" /etc/ssh/sshd_config
Name: sed -i -r "s/^[#P]+ort [0-9][0-9]*/Port 199/" /etc/ssh/sshd_config
Result: True
Comment: Command "sed -i -r "s/^[#P]+ort [0-9][0-9]*/Port 240/" /etc/ssh/sshd_config" run
Started: 23:11:06.415594
Duration: 4.329 ms
Comment: Command "sed -i -r "s/^[#P]+ort [0-9][0-9]*/Port 199/" /etc/ssh/sshd_config" run
Started: 23:47:15.087670
Duration: 3.708 ms
Changes:
----------
pid:
3939
4319
retcode:
0
stderr:
@ -473,9 +488,9 @@ orjakone:
Function: service.running
Name: ssh.service
Result: True
Comment: Started Service ssh.service
Started: 23:11:06.861530
Duration: 58.559 ms
Comment: Service restarted
Started: 23:47:15.109629
Duration: 22.164 ms
Changes:
----------
ssh.service:
@ -483,28 +498,28 @@ orjakone:
----------
ID: ssh_new_port_inform
Function: cmd.run
Name: echo "new SSH daemon port for $(hostname) is 240"
Name: echo "new SSH daemon port for $(hostname) is 199"
Result: True
Comment: Command "echo "new SSH daemon port for $(hostname) is 240"" run
Started: 23:11:06.920584
Duration: 62.236 ms
Comment: Command "echo "new SSH daemon port for $(hostname) is 199"" run
Started: 23:47:15.132159
Duration: 3.246 ms
Changes:
----------
pid:
3954
4329
retcode:
0
stderr:
stdout:
new SSH daemon port for minion is 240
new SSH daemon port for minion is 199
Summary for orjakone
------------
Succeeded: 4 (changed=3)
Succeeded: 5 (changed=3)
Failed: 0
------------
Total states run: 4
Total run time: 129.930 ms
Total states run: 5
Total run time: 460.374 ms
```
Näyttäisi siltä, että portti 240 on generoitu uudeksi SSH daemonin yhteysportiksi koneelle 'orjakone'. Varmistetaan tietojen oikeellisuus. Tämän voi tehdä etänä SSH-yhteyden avulla muultakin koneelta (testataan yhteyden toimivuus orjakoneen IP:een SSH clientilla porttia 240 käyttäen),


Loading…
Cancel
Save