天天看点

Linux Token 一次性密码认证

中国广东省深圳市龙华新区民治街道溪山美地

518131

+86 13113668890

+86 755 29812080

中国广东省深圳市南山区

+86 18665871161

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

Linux Token 一次性密码认证

文档出处:

<a target="_top" href="http://netkiller.github.io/">http://netkiller.github.io</a>

<a target="_top" href="http://netkiller.sourceforge.net/">http://netkiller.sourceforge.net</a>

2014-08-01

摘要

服务器端脚本:

<a href="https://github.com/oscm/devops/blob/master/bin/chpasswd.sh">https://github.com/oscm/devops/blob/master/bin/chpasswd.sh</a>

手机应用:

<a href="https://github.com/oscm/token">https://github.com/oscm/token</a>

我的系列文档

<a target="_top" href="http://netkiller.github.io/architect/index.html">netkiller architect 手札</a>

<a target="_top" href="http://netkiller.github.io/developer/index.html">netkiller developer 手札</a>

<a target="_top" href="http://netkiller.github.io/php/index.html">netkiller php 手札</a>

<a target="_top" href="http://netkiller.github.io/python/index.html">netkiller python 手札</a>

<a target="_top" href="http://netkiller.github.io/testing/index.html">netkiller testing 手札</a>

<a target="_top" href="http://netkiller.github.io/cryptography/index.html">netkiller cryptography 手札</a>

<a target="_top" href="http://netkiller.github.io/linux/index.html">netkiller linux 手札</a>

<a target="_top" href="http://netkiller.github.io/debian/index.html">netkiller debian 手札</a>

<a target="_top" href="http://netkiller.github.io/centos/index.html">netkiller centos 手札</a>

<a target="_top" href="http://netkiller.github.io/freebsd/index.html">netkiller freebsd 手札</a>

<a target="_top" href="http://netkiller.github.io/shell/index.html">netkiller shell 手札</a>

<a target="_top" href="http://netkiller.github.io/security/index.html">netkiller security 手札</a>

<a target="_top" href="http://netkiller.github.io/www/index.html">netkiller web 手札</a>

<a target="_top" href="http://netkiller.github.io/monitoring/index.html">netkiller monitoring 手札</a>

<a target="_top" href="http://netkiller.github.io/storage/index.html">netkiller storage 手札</a>

<a target="_top" href="http://netkiller.github.io/mail/index.html">netkiller mail 手札</a>

<a target="_top" href="http://netkiller.github.io/docbook/index.html">netkiller docbook 手札</a>

<a target="_top" href="http://netkiller.github.io/version/index.html">netkiller version 手札</a>

<a target="_top" href="http://netkiller.github.io/database/index.html">netkiller database 手札</a>

<a target="_top" href="http://netkiller.github.io/postgresql/index.html">netkiller postgresql 手札</a>

<a target="_top" href="http://netkiller.github.io/mysql/index.html">netkiller mysql 手札</a>

<a target="_top" href="http://netkiller.github.io/nosql/index.html">netkiller nosql 手札</a>

<a target="_top" href="http://netkiller.github.io/ldap/index.html">netkiller ldap 手札</a>

<a target="_top" href="http://netkiller.github.io/network/index.html">netkiller network 手札</a>

<a target="_top" href="http://netkiller.github.io/cisco/index.html">netkiller cisco ios 手札</a>

<a target="_top" href="http://netkiller.github.io/h3c/index.html">netkiller h3c 手札</a>

<a target="_top" href="http://netkiller.github.io/multimedia/index.html">netkiller multimedia 手札</a>

<a target="_top" href="http://netkiller.github.io/perl/index.html">netkiller perl 手札</a>

<a target="_top" href="http://netkiller.github.io/radio/index.html">netkiller amateur radio 手札</a>

<a target="_top" href="http://netkiller.github.io/devops/index.html">netkiller devops 手札</a>

目录

<a href="http://netkiller.github.io/journal/token.html#what">1. 什么是token</a>

<a href="http://netkiller.github.io/journal/token.html#why">2. 为什么使用令牌</a>

<a href="http://netkiller.github.io/journal/token.html#when">3. 什么时候能用到令牌技术</a>

<a href="http://netkiller.github.io/journal/token.html#where">4. 本文的token应用在什么地方</a>

<a href="http://netkiller.github.io/journal/token.html#who">5. 谁来部署</a>

<a href="http://netkiller.github.io/journal/token.html#how">6. 手机端配置</a>

<a href="http://netkiller.github.io/journal/token.html#idp56816240">6.1. 设置密码</a>

<a href="http://netkiller.github.io/journal/token.html#idp56824048">6.2. 查看服务器密码</a>

<a href="http://netkiller.github.io/journal/token.html#idp56826432">6.3. 设置刷新时间</a>

token(令牌)是一个身份认证标识,token还有一个特点,那就是存在过期时间的。也就是令牌不是长久有效的。

我们通常需要临时或者一次性使用的身份认证

例如我们去餐厅就餐,向前台获取wifi密码,然后可以享受30分钟的上网服务。30分钟过后密码将失效。

我们公司有很多服务器,密码的管理非常麻烦,有时还会有人事变动,一旦人员发生变动,所有的服务器密码都需要修改一次,非常麻烦,偶尔会有漏改情况,使用堡垒机可以更好的管理密码,但成本非常昂贵。

我采用token技术实现linux指定用户的密码周期变化,以时间为基准,手机同步算出服务器上的密码。为了防止密码被穷举,我增加了4个干扰字符。

如果对密码算法强度感到不安全,你可以自行修改复杂度。

你还可以远程修改密码,不多讲。

首先由管理员部署密码修改程序 chpasswd.sh 然后加入到crontab 中定时运行。

由于考虑到读者的水平参差不齐,所以我使用shell完成,这样绝大多数读者都能看懂。

~/.lastpasswd 中保存最后一次密码

crontab 设置,每分钟修改一次密码。

a b c d 自行设定,设定与手机端相同即可

至此服务器端配置完成

安装token.apk文件到你的手机

<a target="_top" href="https://github.com/oscm/token">https://github.com/oscm/token</a>

Linux Token 一次性密码认证
Linux Token 一次性密码认证

确认密码

Linux Token 一次性密码认证

选择环境

Linux Token 一次性密码认证

设置干扰码

Linux Token 一次性密码认证
Linux Token 一次性密码认证

默认1分钟刷新一次,可能没有来得及输入完密码就会更新密码

如果修改此项,服务器端crontab中的设置同步更改即可。

Linux Token 一次性密码认证

继续阅读