✓ Solved
How Can I Disable SSH On My LKE Worker Nodes?
Linode
Linode Staff
I would like to secure my LKE cluster's worker nodes by disabling SSH. Is this possible?
1 Reply
bshoemaker
Linode Staff
✓ Best Answer
You can automatically stop and disable SSH across all present and future worker nodes by utilizing a daemonset like this:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: disable-ssh
namespace: kube-system
spec:
selector:
matchLabels:
run: disable-ssh
template:
metadata:
labels:
run: disable-ssh
spec:
# needs hostPID to use systemctl
hostPID: true
# tolerate everyting
tolerations:
- operator: Exists
containers:
- name: startup-script
image: gcr.io/google-containers/startup-script:v1
securityContext:
privileged: true
env:
- name: STARTUP_SCRIPT
value: |
#!/bin/bash
set -o errexit
set -o xtrace
if systemctl is-active ssh.service; then
systemctl stop ssh.service
fi
if systemctl is-enabled ssh.service; then
systemctl disable ssh.service
fi