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

SSH reliability settings #317

Merged
merged 15 commits into from
Aug 19, 2024
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,14 @@ jobs:
&& rm -f "\${tmphosts}" \
&& getent hosts api.${{ matrix.subdomain }}.${{ matrix.dns_tld }} | grep 127.0.1.1

sshd -T
service ssh restart

# https://forums.docker.com/t/docker-compose-through-ssh-failing-and-referring-to-docker-example-com/115165/18
- path: /etc/ssh/sshd_config.d/00-cloud-init
content: |
MaxStartups 100:0:100
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the actual fix


# cloud-init runs as root
# (e.g.) https://cloudinit.readthedocs.io/en/latest/reference/merging.html#example-cloud-config
runcmd:
Expand Down Expand Up @@ -839,6 +847,10 @@ jobs:
aws ec2 wait instance-running --instance-ids "${instance_id}"
with_backoff aws ec2 wait instance-status-ok --instance-ids "${instance_id}"

private_ip="$(aws ec2 describe-instances --instance-id "${instance_id}" \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to use this in the future

| jq -r .Reservations[].Instances[].PrivateIpAddress)"
echo "private_ip=${private_ip}" >>"${GITHUB_OUTPUT}"

env:
ATTEMPTS: 2
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION || 'us-east-1' }}
Expand Down Expand Up @@ -876,10 +888,20 @@ jobs:
trap 'log_output' EXIT

# https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html
mkdir -p "${HOME}/.ssh/controlmasters"
cat << EOF > "${HOME}/.ssh/config"
host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null

host i-*
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
TCPKeepAlive yes
ServerAliveInterval 5
ControlPath "${HOME}/.ssh/controlmasters/%r@%h:%p"
ControlMaster auto
ControlPersist 5m
ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
EOF

Expand Down
Loading