Created
November 23, 2021 06:44
-
-
Save catwhocode/337767d0ed8c09a09f67d64c18f8961c to your computer and use it in GitHub Desktop.
Editing SSHD Config Programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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