配置动态码登录服务器

本文详细介绍了如何在Linux系统上配置本地YUM源,安装必要的软件包,以及如何使用GoogleAuthenticator增强SSH服务的安全性,包括设置时间、编译安装、配置SSH和启用动态验证码登录。
摘要由CSDN通过智能技术生成

配置本地yum源

[root@localhost ~]# yum install -y git automake libtool pam-devel bzip2 wget vim ntpdate

校对时间

#修改时区
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai
#校对时间
[root@localhost ~]# ntpdate time.windows.com

下载工具包

[root@localhost ~]# wget http://repository.timesys.com/buildsources/l/libpam-google-authenticator/libpam-google-authenticator-1.0/libpam-google-authenticator-1.0-source.tar.bz2

解压

[root@localhost ~]# tar -xjvf libpam-google-authenticator-1.0-source.tar.bz2

编译安装

[root@localhost ~]# cd libpam-google-authenticator-1.0
[root@localhost ~]# make && make install

修改ssh服务的配置

[root@localhost ~]# echo "auth required pam_google_authenticator.so" >> /etc/pam.d/sshd
#修改sshd配置文件
[root@localhost ~]# vim /etc/ssh/sshd_config
	ChallengeResponseAuthentication yes
#重启sshd服务
[root@localhost ~]# systemctl restart sshd

使用令牌工具生成登录密钥

[root@localhost ~]# google-authenticator
google-authenticator 

Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@localhost.localdomain%3Fsecret%3DWLJCY4JSNGQNH454

Do you want me to update your "/root/.google_authenticator" file (y/n) y
#是否要我更新您的“/root/.google_authenticator”文件
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
#是否要禁止多次使用同一身份验证令牌?这限制您大约每 30 秒登录一次,但它会增加您注意到甚至阻止中间人攻击的机会
By default, tokens are good for 30 seconds and 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. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) y
#默认情况下,令牌的有效期为 30 秒,以便补偿客户端和服务器之间可能存在时间偏差,我们允许额外的当前时间之前和之后的令牌。如果您遇到以下问题时间同步,您可以从其默认值增加窗口大小为1:30min至约4min。是否要这样做
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) n
#如果您登录的计算机未针对暴力破解进行强化登录尝试时,您可以为身份验证模块启用速率限制。默认情况下,这会将攻击者限制为每 30 秒不超过 3 次登录尝试。是否要启用速率限制

使用动态码登录服务器

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值