Files
semaphore/playbooks/change_ssh_port_win.yml
T
Claude Sonnet 5 8ff6d59ba6 Restore from Gitea ZIP snapshot (12.08.2026) after full instance reinstall
Git history was lost when the previous Gitea instance was wiped and
reinstalled due to an unresolved corruption bug — this commit is the
last known-good file content, exported before the reinstall. Prior
commit history is not recoverable through this path.
2026-08-12 19:24:02 +00:00

40 lines
1.0 KiB
YAML

---
- name: Change SSH Port on Windows
hosts: windows
gather_facts: no
# ДОБАВИТЬ ЭТОТ БЛОК:
collections:
- ansible.windows
- community.windows
vars:
new_ssh_port: 22233
sshd_config_path: 'C:\ProgramData\ssh\sshd_config'
tasks:
- name: Allow new SSH port in Windows Firewall
# Теперь можно писать короче, так как коллекции подключили выше
win_firewall_rule:
name: "OpenSSH-Server-Custom-Port"
localport: "{{ new_ssh_port }}"
action: allow
direction: in
protocol: tcp
profiles: domain,private,public
state: present
enabled: yes
- name: Update Port in sshd_config
win_lineinfile:
path: "{{ sshd_config_path }}"
regexp: '^#?Port\s+\d+'
line: "Port {{ new_ssh_port }}"
state: present
notify: Restart Windows SSH
handlers:
- name: Restart Windows SSH
win_service:
name: sshd
state: restarted