Last active
July 5, 2018 08:28
-
-
Save hieunba/efa1f1fc9b549b4dd6f44fa21d55504e to your computer and use it in GitHub Desktop.
Oxi Hardening
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
| #!/bin/bash | |
| # check root | |
| if [[ `id -u` -ne 0 ]] ; then | |
| echo "Please run this under root." | |
| echo 1 | |
| fi | |
| # Hardening SSH | |
| harden-ssh() { | |
| # backup | |
| SSH_PORT="55059" | |
| SSHD_CONF="/etc/ssh/sshd_config" | |
| # port changing | |
| cp -f ${SSHD_CONF} "${SSHD_CONF}.bak" | |
| cat > /etc/ufw/applications.d/oxi-openssh-server <<END | |
| [OpenSSH-Oxi] | |
| title=Secure shell server, an rshd replacement | |
| description=OpenSSH is a free implementation of the Secure Shell protocol. | |
| ports=${SSH_PORT}/tcp | |
| END | |
| # change port | |
| echo "Changing port to ${SSH_PORT}" | |
| sed -i "/Port/ s/22/${SSH_PORT}/" ${SSHD_CONF} | |
| # apply changes | |
| ufw allow OpenSSH-Oxi | |
| systemctl restart ssh.service | |
| } | |
| ## start | |
| harden-ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment