Repository navigation
Setup and SSH Migration
playbooks/setup.yaml is safe to rerun. It configures the server baseline and
switches the Ansible connection to the hardened SSH port.
The default hardened port is 22571, but a fresh server normally still listens on 22. Tell the playbook where it can connect now:
uv run ansible-playbook \
-i inventories/production/hosts.yaml \
--ask-vault-pass \
playbooks/setup.yaml \
-e 'setup_ssh_port=22'Before this command:
- Allow TCP 22571 in the cloud security group, provider firewall, and any NAT.
- Confirm the bootstrap user can use
sudo -n true. - Keep console or provider serial access available.
The setup pre-task temporarily permits both the old current SSH port and the new hardened port in the local firewall. It flushes firewall handlers before the SSH service is reconfigured, then resets Ansible's SSH connection.
After migration, the default setup_ssh_port resolves to the hardened port:
uv run ansible-playbook \
-i inventories/production/hosts.yaml \
--ask-vault-pass \
playbooks/setup.yamlExample: migrate from 22571 to 2223.
# First open TCP 2223 in every upstream network control.
uv run ansible-playbook \
-i inventories/production/hosts.yaml \
--ask-vault-pass \
playbooks/setup.yaml \
-e 'setup_ssh_port=22571' \
-e 'ssh_hardening_port=2223'
ssh -i ~/.ssh/id_ed25519 -p 2223 bootstraper@203.0.113.10 'sudo -n true'Only remove the old upstream firewall rule after the new SSH command succeeds.
ssh_hardening_current_port is the port visible to the managed host's local
firewall during migration. If your public/NAT port differs from that local port,
set it explicitly. Example:
uv run ansible-playbook playbooks/setup.yaml \
-e 'setup_ssh_port=22571' \
-e 'ssh_hardening_current_port=22'Do not copy this example blindly. Set the value to the port that the server actually receives after NAT translation.
Setup runs, in order:
ssh_hardeningiptables_firewallsystem_tools-
dockerandtraefikontraefik_hosts -
crowdsecon every host
If setup fails, rerun the same command after correcting the error. Do not skip
directly to apps.yaml.