fixing ssh
This commit is contained in:
@@ -106,24 +106,27 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y openssh-server
|
sudo apt-get install -y openssh-server
|
||||||
|
|
||||||
|
# Ensure privilege separation directory exists
|
||||||
|
sudo mkdir -p /run/sshd
|
||||||
|
|
||||||
# Generate host keys if missing
|
# Generate host keys if missing
|
||||||
sudo ssh-keygen -A
|
sudo ssh-keygen -A
|
||||||
|
|
||||||
# Start sshd on a custom port 2222 to avoid port conflicts on the runner host
|
# Start sshd on a custom port 2222 to avoid port conflicts on the runner host
|
||||||
sudo /usr/sbin/sshd -p 2222 -o "ListenAddress 127.0.0.1" -o "UsePAM yes"
|
sudo /usr/sbin/sshd -p 2222 -o "ListenAddress 127.0.0.1" -o "UsePAM yes"
|
||||||
|
|
||||||
# Configure passwordless SSH login for current user
|
# Configure passwordless SSH login for current user
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_test
|
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_test
|
||||||
cat ~/.ssh/id_test.pub >> ~/.ssh/authorized_keys
|
cat ~/.ssh/id_test.pub >> ~/.ssh/authorized_keys
|
||||||
chmod 700 ~/.ssh
|
chmod 700 ~/.ssh
|
||||||
chmod 600 ~/.ssh/authorized_keys
|
chmod 600 ~/.ssh/authorized_keys
|
||||||
|
|
||||||
# Establish environment variables for subsequent steps
|
# Establish environment variables for subsequent steps
|
||||||
echo "SSH_USER=$(whoami)" >> "$GITHUB_ENV"
|
echo "SSH_USER=$(whoami)" >> "$GITHUB_ENV"
|
||||||
echo "TEST_REMOTE_DIR=$HOME/ssh_deploy_test" >> "$GITHUB_ENV"
|
echo "TEST_REMOTE_DIR=$HOME/ssh_deploy_test" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Write the private key to GitHub/Gitea env securely using multiline syntax
|
# Write the private key to GitHub/Gitea env securely using multiline syntax
|
||||||
echo "SSH_PRIVATE_KEY<<EOF" >> "$GITHUB_ENV"
|
echo "SSH_PRIVATE_KEY<<EOF" >> "$GITHUB_ENV"
|
||||||
cat ~/.ssh/id_test >> "$GITHUB_ENV"
|
cat ~/.ssh/id_test >> "$GITHUB_ENV"
|
||||||
@@ -166,7 +169,7 @@ jobs:
|
|||||||
STATUS=$(docker ps --filter "name=pipeline-actions-ssh-test" --format "{{.Status}}")
|
STATUS=$(docker ps --filter "name=pipeline-actions-ssh-test" --format "{{.Status}}")
|
||||||
echo "Container status: ${STATUS}"
|
echo "Container status: ${STATUS}"
|
||||||
echo "${STATUS}" | grep -q "Up" || { echo "Container is not running"; exit 1; }
|
echo "${STATUS}" | grep -q "Up" || { echo "Container is not running"; exit 1; }
|
||||||
|
|
||||||
echo "Checking image pin..."
|
echo "Checking image pin..."
|
||||||
IMAGE_USED=$(docker inspect pipeline-actions-ssh-test --format '{{.Config.Image}}')
|
IMAGE_USED=$(docker inspect pipeline-actions-ssh-test --format '{{.Config.Image}}')
|
||||||
echo "Container is using image: ${IMAGE_USED}"
|
echo "Container is using image: ${IMAGE_USED}"
|
||||||
|
|||||||
Reference in New Issue
Block a user