天天看點

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 一次性密碼認證

繼續閱讀