Skip to content

Commit

Permalink
add code skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyzhang committed Jun 9, 2017
1 parent 25b399a commit e33dd11
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bash/update_sshd_security/README.md
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
35 changes: 35 additions & 0 deletions bash/update_sshd_security/update_sshd_security.sh
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

0 comments on commit e33dd11

Please sign in to comment.