Last active
September 8, 2019 21:16
-
-
Save bombsimon/215f879c86c6663f900cc860a3c69c0c to your computer and use it in GitHub Desktop.
Disable SSH login
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
#!/bin/bash | |
set -e | |
# Set a default port | |
SSH_PORT=${1:-998} | |
# Disable password login | |
sudo sed -i "/PasswordAuthentication/s/yes/no/g" /etc/ssh/sshd_config | |
# Change port from 22 to ${SSH_PORT} | |
sudo sed -i "/Port/s/22/${SSH_PORT}/g" /etc/ssh/sshd_config | |
# Remove hard coded forced port | |
sudo sed -i "/SSHD_OPTS/s/-p\ 22\ //g" /etc/default/ssh | |
# Restart sshd | |
sudo service ssh restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment