This skill hardens SSH on VPS by enforcing key authentication, disabling root login, and creating non-root sudo users to prevent unauthorized access.
npx playbooks add skill mikr13/secure-server-setup-skills --skill ssh-hardening
Establish working administrative access before restricting authentication. Keep the current session and provider console available until a fresh post-change login succeeds.
Include order, and relevant Match rules. Record sshd -T -C results for the actual users, client addresses, and hostnames.--interactive mode is for a human terminal and --no-passphrase is an explicit service-key choice. ssh -o IdentitiesOnly=yes -o PreferredAuthentications=publickey -i ~/.ssh/server_admin administrator@server.example.com
In that new session, verify the required sudo operation. Password fallback or an already-open session is not proof of usable key access.
Read [references/sshd-config.md](references/sshd-config.md) before editing includes, conditional access or activation.
The [setup helper](scripts/setup-ssh-hardening.sh) supports a conventional key-only policy. It requires an existing non-root administrator; it does not create accounts, replace AllowUsers/AllowGroups, change ports, or remove forwarding functionality. Existing multiple-factor authentication requires a reviewed manual policy instead of this helper.
sudo bash scripts/setup-ssh-hardening.sh --user administrator --client-address 203.0.113.10 --dry-run
After proven key/sudo access and authorization to configure/activate:
sudo bash scripts/setup-ssh-hardening.sh --user administrator --client-address 203.0.113.10 --key-access-confirmed --apply --activate
Repeat --user for administrators that must be verified. Set --client-host when hostname-based Match rules apply. The helper validates the supplied client context; inspect other relevant networks/hostnames as well. It writes a managed early drop-in and refuses success if earlier values or conditional rules override the requested policy. An early filename alone is not proof of precedence.
sudo sshd -t. Effective file policy: sudo sshd -T -C user=administrator,host=client.example.com,addr=203.0.113.10.Report file validation separately from activation and live access tests. Do not describe ClientAliveInterval as a user-idle timeout or hard-code obsolete protocol/crypto settings.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.