Added cockpit cloud-init example

This commit is contained in:
Michele Cereda
2023-03-16 18:32:53 +01:00
parent 9eadaf7a43
commit 69e6e971f4
2 changed files with 45 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
#cloud-config
# Use another port instead of the default 9090. Also, close port 9090 behind.
#
# Tested on:
# - Oracle Linux 8.6
# On cloud instances, remember to open the port in the NSG.
bootcmd:
# `cloud-init` has issues with `firewall-cmd`, using the offline version.
- firewall-offline-cmd --add-port='48763/tcp' --zone='public'
packages:
- cockpit
write_files:
- path: /etc/systemd/system/cockpit.socket.d/listen.conf
content: |
[Socket]
ListenStream=
ListenStream=48763
runcmd:
# Allow the new port in SELinux.
- semanage port -a -t 'websm_port_t' -p 'tcp' '48763'
# Apply the changes.
- systemctl reload 'firewalld.service'
- systemctl daemon-reload
- systemctl restart 'cockpit.socket'

View File

@@ -14,13 +14,26 @@
```sh
# Check ports on hosts.
nc -Nnvz 192.168.0.81 22
nc -Nnvz 192.168.0.81 22-25
nc -Nvz host.name 443
nc -Nvz -u dns.server 123
# List hosts with a specific port open.
# But you might just want to use `nmap`.
parallel -j 0 "nc -Nnvz -w 2 192.168.0.{} 22 2>&1" ::: {2..254} \
| grep -v "timed out"
# Wait for a host to be up.
until nc -Nvz -w 3 pi.lan 22; do sleep 3; done
# Listen mode.
nc -l 5666
```
## Sources
- [How To use Netcat to establish and test TCP and UDP connections]
<!-- project's references -->
[how to use netcat to establish and test tcp and udp connections]: https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections