Kumi
c72c45f47b
Some checks failed
Test! / test (push) Failing after 1m17s
Preemptively creating the `~/.ssh` directory before attempting to add the SSH server's host key to `known_hosts`. This change prevents potential failures in CI workflows where the `.ssh` directory might not exist on a fresh runner environment, ensuring a smoother and more reliable setup for SSH connections. This adjustment enhances the resilience of the testing workflow by avoiding errors related to missing directories, thereby improving automated testing reliability and efficiency.
45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
name: Test!
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Generate SSH key pair
|
|
run: |
|
|
ssh-keygen -t rsa -b 4096 -f my_ssh_key -N ""
|
|
|
|
- name: Install Docker
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y docker.io
|
|
|
|
- name: Build and run SSH Server Docker Container
|
|
run: |
|
|
docker build -t my-ssh-server ./ci-tests/
|
|
docker run -d -p 2222:22 --name ssh-server my-ssh-server
|
|
|
|
- name: Copy public key to Docker container
|
|
run: |
|
|
docker cp my_ssh_key.pub ssh-server:/home/replication/.ssh/authorized_keys
|
|
docker exec ssh-server chown replication:replication /home/replication/.ssh/authorized_keys
|
|
docker exec ssh-server chmod 600 /home/replication/.ssh/authorized_keys
|
|
|
|
- name: Trust SSH server's host key (to prevent interactive prompt)
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
ssh-keyscan -p 2222 -H localhost >> ~/.ssh/known_hosts
|
|
|
|
- name: Connect to SSH server using SSH key
|
|
run: |
|
|
ssh -i my_ssh_key -p 2222 root@localhost echo "SSH connection successful"
|