forked from dennyzhang/devops_public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dennyzhang
committed
Jun 9, 2017
1 parent
25b399a
commit e33dd11
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- sshd listen on another port | ||
- Only take ssh by key, instead of username | ||
- Reset root password |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash -e | ||
##------------------------------------------------------------------- | ||
## @copyright 2016 DennyZhang.com | ||
## Licensed under MIT | ||
## https://raw.githubusercontent.com/DennyZhang/devops_public/tag_v1/LICENSE | ||
## | ||
## File : update_sshd_security.sh | ||
## Author : Denny <[email protected]> | ||
## Description : | ||
## -- | ||
## Created : <2015-05-13> | ||
## Updated: Time-stamp: <2017-06-09 14:20:31> | ||
##------------------------------------------------------------------- | ||
function log() { | ||
local msg=$* | ||
date_timestamp=$(date +['%Y-%m-%d %H:%M:%S']) | ||
echo -ne "$date_timestamp $msg\n" | ||
|
||
if [ -n "$LOG_FILE" ]; then | ||
echo -ne "$date_timestamp $msg\n" >> "$LOG_FILE" | ||
fi | ||
} | ||
|
||
LOG_FILE="/var/log/update_sshd_security.log" | ||
|
||
ssh_port=${1:-"2702"} | ||
root_pwd=${2:-""} | ||
|
||
################################################################################ | ||
# Make sure only root can run our script | ||
if [[ $EUID -ne 0 ]]; then | ||
echo "Error: This script must be run as root." 1>&2 | ||
exit 1 | ||
fi | ||
## File : update_sshd_security.sh ends |