Created
November 3, 2017 12:08
-
-
Save esolitos/988031f172c517dfc628cac29c6bc14a to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
$sshd_conf = file_get_contents('/etc/ssh/sshd_config') | |
?> | |
<h2>Before</h2> | |
<pre> | |
<?php var_dump($sshd_conf) ?> | |
</pre><?php | |
$SnD = array( | |
'@#(PermitEmptyPasswords)(.+)@' => '$1 yes', | |
'@#(PermitRootLogin)(.+)@' => '$1 yes', | |
'@#(PasswordAuthentication)(.+)@' => '$1 yes', | |
); | |
$fixed_conf = preg_replace(array_keys($SnD), array_values($SnD), $sshd_conf); | |
?> | |
<h2>After</h2> | |
<pre> | |
<?php var_dump($fixed_conf) ?> | |
</pre><?php | |
$result = file_put_contents('/etc/ssh/sshd_config', $fixed_conf); | |
exec('kill -HUP ') | |
?> | |
<h2> Replaced? </h2> | |
<pre><?php var_dump($result); ?> </pre> | |
<?php | |
shell_exec('nohup sudo /usr/local/bin/sshd-generate-keys.sh > keygen-out.log 2>&1'); | |
shell_exec('nohup sudo /usr/sbin/sshd -f /etc/ssh/sshd_config > ssh-out.log 2>&1'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment