Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created November 23, 2021 06:44
Show Gist options
  • Save catwhocode/337767d0ed8c09a09f67d64c18f8961c to your computer and use it in GitHub Desktop.
Save catwhocode/337767d0ed8c09a09f67d64c18f8961c to your computer and use it in GitHub Desktop.
Editing SSHD Config Programmatically
#!/usr/bin/env sh
file=/etc/ssh/sshd_config
cp -p $file $file.old &&
awk '
$1=="#PasswordAuthentication" {$1="PasswordAuthentication"; $2="no"}
$1=="#PubkeyAuthentication" {$1="PubkeyAuthentication"; $2="yes"}
{print}
' $file.old > $file
https://gunargessner.com/edit-sshd-config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment