I attempted to deploy using a GitHub Actions workflow, but failed due to OpenVPN setting. I want to connect to an AWS server using SSH, but in order to connect, I have to connect to OpenVPN first.
The information I know about OpenVPN is ca, cert, key, tls-crypt. Can anyone please give me a clue about connecting to OpenVPN using GitHub Actions workflow?
the code provided below. I do not know if it works without openvpn username and password. I want to connect without username and password because I do not have them. I have only .ovpn
file.
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Open VPN
run: sudo apt-get update && sudo apt-get install -y openvpn
- name: Connect VPN
uses: golfzaptw/action-connect-ovpn@master
id: connect_vpn
with:
PING_URL: ${{ secrets.REMOTE_HOST_URL }}
FILE_OVPN: '.github/vpn/config.ovpn'
env:
CA_CRT: ${{ secrets.CA_CRT}}
USER_CRT: ${{ secrets.USER_CRT }}
USER_KEY: ${{ secrets.USER_KEY }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
Occurred below error
Run golfzaptw/action-connect-ovpn@master
/bin/sh: 2: ***: not found
/bin/sh: 3: ***: not found
/bin/sh: 4: ***: not found
/bin/sh: 5: ***: not found
/bin/sh: 6: ***: not found
/bin/sh: 7: ***: not found
/bin/sh: 8: ***: not found
/bin/sh: 9: ***: not found
/bin/sh: 10: ***: not found
/bin/sh: 11: ***: not found
/bin/sh: 12: -----END: not found
/bin/sh: 2: ***: not found
/bin/sh: 3: ***: not found
/bin/sh: 4: ***: not found
/bin/sh: 5: ***: not found
/bin/sh: 6: ***: not found
/bin/sh: 7: ***: not found
/bin/sh: 8: ***: not found
/bin/sh: 9: ***: not found
/bin/sh: 10: ***: not found
/bin/sh: 12: -----END: not found
/bin/sh: 2: ***: not found
/bin/sh: 3: ***: not found
/bin/sh: 4: ***: not found
/bin/sh: 5: -----END: not found
Error: Can't setup config /home/runner/work/apiserver/apiserver/.github/vpn/config.ovpn
You need to have the OpenVPN client installed on your GHA runner. You can use its CLI to connect to your OpenVPN server (most probably, in the background mode) before SSHing to your AWS server.
For example, see Connecting to Access Server with Linux. You may have to backup
/etc/resolv.conf
and later restore it also once you're done with VPN and need normal connectivity (if required depending on your use case).To automate these things, you can find already published actions on the GHA marketplace.