ssh-i/path/id_rsa_test-04user@test-04# 首次连接时不检查公钥,即不弹出Are you sure you want to continue connecting (yes/no/[fingerprint])?ssh-i/path/id_rsa_test-04-oStrictHostKeyChecking=nouser@test-04
DENY_IP_LIST=`cat /var/log/secure* | grep "Invalid user" | awk -F ' ' '{print $10}'| sort | uniq -cd | sort -n | awk -F ' ' '{if ($1 >= 10) print $2}'| grep '^[0-9]'`
for a in $DENY_IP_LIST
do
grep $a /etc/hosts.deny > /dev/null 2>&1
if [ $? -gt 0 ]; then
echo "sshd:$a:deny # "`date +%F` >> /etc/hosts.deny
fi
done
#! /bin/bash
DENY_IP_LIST=`cat /var/log/secure* | grep "Invalid user" | awk -F ' ' '{print $10}'| sort | uniq -cd | sort -n | awk -F ' ' '{if ($1 >= 3) print $2}'| grep '^[0-9]'`
for a in $DENY_IP_LIST
do
grep $a /etc/hosts.deny > /dev/null 2>&1
if [ $? -gt 0 ]; then
echo "ALL:$a:deny" >> /etc/hosts.deny
fi
done
wait
DENY_IP_LIST_2=`cat /var/log/secure* | grep rhost | awk -F ' ' '{print $14}' | awk -F '=' '{print$2}' | sort | uniq -cd | sort -n | awk -F ' ' '{if ($1 >= 3) print $2}'`
for b in $DENY_IP_LIST_2
do
grep $b /etc/hosts.deny > /dev/null 2>&1
if [ $? -gt 0 ]; then
echo "ALL:$b:deny" >> /etc/hosts.deny
fi
done
wait
DENY_IP_LIST_3=`cat /var/log/secure* | grep "Failed password for" | awk -F ' ' '{print $(NF-3)}' | sort | uniq -cd | sort -n | awk -F ' ' '{if ($1 >= 3) print $2}'`
for c in $DENY_IP_LIST_3
do
grep $c /etc/hosts.deny > /dev/null 2>&1
if [ $? -gt 0 ]; then
echo "ALL:$c:deny" >> /etc/hosts.deny
fi
done
yum install -y google-authenticator # 安装
google-authenticator # 开始配置
Do you want authentication tokens to be time-based (y/n) y
Warning: pasting the following URL into your browser exposes the OTP secret to Google:
https://www.google.com/chart?chs=200x200&chld=M&cht=qr&chl=otpauth://totp/root@TEST-01%3Fsecret%3DOCT7BGIIG3TPHFEBT4ZHAXQJCY%26issuer%3DTEST-01
Your new secret key is: OCT7BGIIG3TPHFEBT4ZHAXQJCY
Your verification code is 292118
Your emergency scratch codes are:
75790075
10624502
34743379
10201854
30805825
Do you want me to update your "/root/.google_authenticator" file? (y/n) y
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y
By default, a new token is generated every 30 seconds by the mobile app.
In order to compensate for possible time-skew between the client and the server,
we allow an extra token before and after the current time. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) y # 服务器跟手机时间如果不一至,会导致两者之间算出来的验证码不一样,可以通过允许两者之间的时间偏差来使用一定时间范围内的验证码(范围为前1中1后1总计3个到前8中1后8总计17个),可以在~/.google-authenticator 中修改" WINDOW_SIZE 17来调整。
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting? (y/n) y