diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..4ce0e7e --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,30 @@ +name: Testing + +on: + push: + pull_request: + + testing: + runs-on: ubuntu-latest + container: golang:1.20-alpine + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: setup sshd server + run: | + apk add git make curl perl bash build-base zlib-dev ucl-dev + make ssh-server + + - name: executing remote ssh commands using password + uses: ./ + with: + host: 127.0.0.1 + username: drone-ssh + password: 1234 + port: 22 + script: whoami + + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6bbe50b --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +ssh-server: + adduser -h /home/drone-ssh -s /bin/sh -D -S drone-ssh + echo drone-ssh:1234 | chpasswd + mkdir -p /home/drone-ssh/.ssh + chmod 700 /home/drone-ssh/.ssh + cat tests/.ssh/id_rsa.pub >> /home/drone-ssh/.ssh/authorized_keys + cat tests/.ssh/test.pub >> /home/drone-ssh/.ssh/authorized_keys + chmod 600 /home/drone-ssh/.ssh/authorized_keys + chown -R drone-ssh /home/drone-ssh/.ssh + # install ssh and start server + apk add --update openssh openrc + rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key + sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config + sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config + ./tests/entrypoint.sh /usr/sbin/sshd -D &