Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Host ssh signer for know_hosts verification #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,17 @@ master:
# Path to deploy. Can be auto-determined using EE version if not specified explicitly.
deploy_path: /opt/easyengine/sites/example.com/app/htdocs


# Setting these options because of ssh-issues in GH actions.
# Should not be needed in future, hopefully :fingers-crossed:
sshOptions:
UserKnownHostsFile: /dev/null
StrictHostKeyChecking: no

staging:
hostname: stag.example.com
user: root
stage: develop
deploy_path: /opt/easyengine/sites/stag.example.com/app/htdocs
sshOptions:
UserKnownHostsFile: /dev/null
StrictHostKeyChecking: no

develop:
hostname: dev.example.com
user: root
stage: develop
deploy_path: /opt/easyengine/sites/dev.example.com/app/htdocs
sshOptions:
UserKnownHostsFile: /dev/null
StrictHostKeyChecking: no

ci_script_options:
vip: true
Expand Down
11 changes: 8 additions & 3 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@ ssh-keygen -t rsa -b 4096 -C "GH-actions-ssh-deploy-key" -f "$HOME/.ssh/id_rsa"
# Get signed key from vault
vault write -field=signed_key ssh-client-signer/sign/my-role public_key=@$HOME/.ssh/id_rsa.pub > $HOME/.ssh/signed-cert.pub

# Setup known_hosts
known_hosts_file="${SSH_DIR}/known_hosts"
known_host_data="@cert-authority ${hostname} "
host_signer=$(vault read -field=public_key ssh-host-signer/config/ca)
known_host_data="${known_host_data}${host_signer}"
echo "$known_host_data" >> "$known_hosts_file"

# Create ssh config file. `~/.ssh/config` does not work.
cat > /etc/ssh/ssh_config <<EOL
Host $hostname
HostName $hostname
IdentityFile ${HOME}/.ssh/signed-cert.pub
IdentityFile ${HOME}/.ssh/id_rsa
UserKnownHostsFile $known_hosts_file
User root
EOL

# echo "$SSH_KNOWN_HOSTS" | tr -d '\r' > "$SSH_DIR/known_hosts"
# chmod 644 "$SSH_DIR/known_hosts"

mkdir -p "$HTDOCS"
cd "$HTDOCS"
export build_root="$(pwd)"
Expand Down