From 69e6e971f49901eee7ac4e09714ba3091478a683 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 16 Mar 2023 18:32:53 +0100 Subject: [PATCH] Added cockpit cloud-init example --- examples/cloud-init/cockpit.yaml | 31 +++++++++++++++++++++++++++++++ knowledge base/nc.md | 15 ++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 examples/cloud-init/cockpit.yaml diff --git a/examples/cloud-init/cockpit.yaml b/examples/cloud-init/cockpit.yaml new file mode 100644 index 0000000..1caf54f --- /dev/null +++ b/examples/cloud-init/cockpit.yaml @@ -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' diff --git a/knowledge base/nc.md b/knowledge base/nc.md index 9c06412..3b589c0 100644 --- a/knowledge base/nc.md +++ b/knowledge base/nc.md @@ -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] + + + +[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