From 2fe99bde736e1889d8f1a9e8dc3f66d70eac6c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Anguita=20L=C3=B3pez?= Date: Fri, 11 Oct 2024 17:30:21 +0200 Subject: [PATCH] change SSH port in the AMI instance --- .github/workflows/packages_builder_ami.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/packages_builder_ami.yaml b/.github/workflows/packages_builder_ami.yaml index fcd6bda..e511b96 100644 --- a/.github/workflows/packages_builder_ami.yaml +++ b/.github/workflows/packages_builder_ami.yaml @@ -119,13 +119,6 @@ jobs: echo "[gha_instance]" > ${{ env.ALLOCATOR_PATH }}/inventory_ansible.ini echo "${{ env.ansible_host }} ansible_port=${{ env.ansible_port }} ansible_user=${{ env.ansible_user }} ansible_ssh_private_key_file=${{ env.ansible_ssh_private_key_file }} ansible_ssh_common_args='${{ env.ansible_ssh_common_args }}'" >> ${{ env.ALLOCATOR_PATH }}/inventory_ansible.ini - - name: Change SSH port - run: | - ssh -i "${{ env.ansible_ssh_private_key_file }}" -o StrictHostKeyChecking=no -p ${{ env.ansible_port }} ${{ env.ansible_user }}@${{ env.ansible_host }} << 'EOF' - sudo sed -i 's/^Port 2200/Port 22/' /etc/ssh/sshd_config - sudo systemctl restart sshd - EOF - - name: Run Ansible playbook to install Wazuh components run: | ansible-playbook -i ${{ env.ALLOCATOR_PATH }}/inventory_ansible.ini ${{ env.PLAYBOOKS_PATH }}/build_ami_packages.yaml --extra-vars "installation_assistant_reference=${{ inputs.WAZUH_INSTALLATION_ASSISTANT_REFERENCE }}" ${{ inputs.VERBOSITY }} @@ -134,6 +127,13 @@ jobs: run: | aws ec2 stop-instances --instance-ids ${{ env.identifier }} + - name: Change SSH port + run: | + ssh -i "${{ env.ansible_ssh_private_key_file }}" -o StrictHostKeyChecking=no -p ${{ env.ansible_port }} ${{ env.ansible_user }}@${{ env.ansible_host }} << 'EOF' + sudo sed -i 's/^Port 2200/Port 22/' /etc/ssh/sshd_config + sudo systemctl restart sshd + EOF + - name: Check EC2 instance status until stopped id: check_status run: |